Title: [API Question] Parentheses affects declaration emit. Intentional? · Issue #32824 · microsoft/TypeScript · GitHub
Open Graph Title: [API Question] Parentheses affects declaration emit. Intentional? · Issue #32824 · microsoft/TypeScript
X Title: [API Question] Parentheses affects declaration emit. Intentional? · Issue #32824 · microsoft/TypeScript
Description: Consider the following snippet, /* The below types are exactly the same. The only difference is that one is wrapped in parentheses. The other is not. */ type InvalidKeys
Open Graph Description: Consider the following snippet, /* The below types are exactly the same. The only difference is that one is wrapped in parentheses. The other is not. */ type InvalidKeys X Description: Consider the following snippet, /* The below types are exactly the same. The only difference is that one is wrapped in parentheses. The other is not. */ type InvalidKeys<K extends string|number|...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/32824
X: @github
Domain: github.com
Links:
Viewport: width=device-width
Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[API Question] Parentheses affects declaration emit. Intentional?","articleBody":"Consider the following snippet,\r\n\r\n```ts\r\n/*\r\n The below types are exactly the same.\r\n The only difference is that one is wrapped in parentheses.\r\n The other is not.\r\n*/\r\n\r\ntype InvalidKeys\u003cK extends string|number|symbol> = { [P in K]? : never };\r\ntype InvalidKeys2\u003cK extends string|number|symbol> = (\r\n { [P in K]? : never }\r\n);\r\n\r\ntype A\u003cT> = (\r\n T & InvalidKeys\u003c\"a\">\r\n);\r\ntype A2\u003cT> = (\r\n T & InvalidKeys2\u003c\"a\">\r\n);\r\n\r\n/*\r\n type a = {\r\n x: number;\r\n } & InvalidKeys\u003c\"a\">\r\n */\r\ntype a = A\u003c{ x : number }>;\r\n/*\r\n type a2 = {\r\n x: number;\r\n } & {\r\n a?: undefined;\r\n }\r\n*/\r\ntype a2 = A2\u003c{ x : number }>;\r\n\r\n/*\r\n One parentheses is all you need to change the output\r\n*/\r\n```\r\n\r\n[Playground](http://www.typescriptlang.org/play/#code/PQKgUABFECoBYFMICMEBsD2B3CAXAngA4IDOEAhgE5IIAe5AxrmvnohCeQLYIB0k0eEgwA7FhAAmASwBmMhNREMkUsrjjlcEUSrJZK5QsQkQpIiISoIR60qX7RY7DLcqmyIl-xDAwYAsQQAJIiAG7kaFISANII+CQAPNEQdLjWEmQkuJRmAOYAPiIArlyolPkk+KUYaAB8EAC8EADeEADaAAqm5tEAugD8EABcECIIoQoQAL4A3P5ESCHhkTFxJABMSSm0aSIZHNl5hSVlFVXINfVNABQCUK2d3RB9gyNjE25TYACUc-OBAEEEjArhBbo4YBAAGTBMIRKKxeIJABE5GRtR+cwCSABmxBjTBd1g0NhywRa02qPRmL8oCJ2IoBOaRMctDeJwUc0cUxJS3hqyRVIxEB8-yQ5AJQNatGGow5n1qczpjgZ5HWTJZ0DZctKnKJPJhzMcjnI-RGRT2CBkZgQEi50C+otV6qauIS0tlxV1Cr+yugAHkxhYrDZECRSO4KGg0BB8BgiqMELa8BgIAwNCJckhbNoirhCHmwD4gA)\r\n\r\nI've noticed that, sometimes, the presence/absence of parentheses can change the emitted type declaration. Is this intentional? If so, are there set rules for it? Can this behaviour be relied upon?\r\n\r\nThere are times where one would **want** the type to be expanded. And other times where one would **not** want the type to be expanded.\r\n\r\nHaving control over it would be nice. (I know I've wanted control over it plenty of times).\r\n\r\n-----\r\n\r\nI have encountered this discrepancy multiple times but this is the most recent example,\r\n(that inspired me to finally make this issue).\r\nhttps://github.com/microsoft/TypeScript/issues/20863#issuecomment-520551758\r\n\r\nThe `InvalidKeys` type is not expanded because I did not wrap the type in parentheses.\r\n\r\n-----\r\n\r\nObligatory @keithlayne , who hates unnecessary parentheses :trolleybus: ","author":{"url":"https://github.com/AnyhowStep","@type":"Person","name":"AnyhowStep"},"datePublished":"2019-08-12T19:50:49Z","url":"https://github.com/microsoft/TypeScript/issues/32824"}
react-profiling 0 react-import-map react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 route-pattern /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) route-controller voltron_issues_fragments route-action issue_layout fetch-nonce v2:f4b028f2-3c49-cc0e-740a-03cac0646c75 current-catalog-service-hash 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 request-id C2EC:E3C4F:2A323FF:35D1608:6B01AF86 html-safe-nonce 7344085af627fa60ea6c98910e3dcd5127d6af37b7591309641216e011298832 visitor-payload eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMkVDOkUzQzRGOjJBMzIzRkY6MzVEMTYwODo2QjAxQUY4NiIsInZpc2l0b3JfaWQiOiIyMjYwNTAyNTcwMjczNDUxOTEwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= visitor-hmac ca809d175bfded068352c993d7e533361d1dbfa3612d0d99a0bbf627a73f8b1b hovercard-subject-tag issue:479820236 github-keyboard-shortcuts repository,issues,copilot google-site-verification Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I octolytics-url https://collector.github.com/github/collect analytics-location / fb:app_id 1401488693436528 apple-itunes-app app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/32824/issue_layout twitter:image https://opengraph.githubassets.com/d42cc78ff0ab1612e661eea5c56985b4c677480c2fb44da0505b98c3e7670a68/microsoft/TypeScript/issues/32824 twitter:card summary_large_image og:image https://opengraph.githubassets.com/d42cc78ff0ab1612e661eea5c56985b4c677480c2fb44da0505b98c3e7670a68/microsoft/TypeScript/issues/32824 og:image:alt Consider the following snippet, /* The below types are exactly the same. The only difference is that one is wrapped in parentheses. The other is not. */ type InvalidKeys og:image:width 1200 og:image:height 600 og:site_name GitHub og:type object og:author:username AnyhowStep hostname github.com expected-hostname github.com None cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c turbo-cache-control no-preview go-import github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git octolytics-dimension-user_id 6154722 octolytics-dimension-user_login microsoft octolytics-dimension-repository_id 20929025 octolytics-dimension-repository_nwo microsoft/TypeScript octolytics-dimension-repository_public true octolytics-dimension-repository_is_fork false octolytics-dimension-repository_network_root_id 20929025 octolytics-dimension-repository_network_root_nwo microsoft/TypeScript turbo-body-classes logged-out env-production page-responsive disable-turbo false browser-stats-url https://api.github.com/_private/browser/stats browser-errors-url https://api.github.com/_private/browser/errors release 8c77c9e8439031ad54c75a250694842892f693e1 ui-target full theme-color #1e2327 color-scheme light dark react-app-name issues
URLs of crawlers that visited me.