Title: Explicitly annotated unique symbols are widened in return positions · Issue #55361 · microsoft/TypeScript · GitHub
Open Graph Title: Explicitly annotated unique symbols are widened in return positions · Issue #55361 · microsoft/TypeScript
X Title: Explicitly annotated unique symbols are widened in return positions · Issue #55361 · microsoft/TypeScript
Description: 🔎 Search Terms widening return unique symbol 🕗 Version & Regression Information This is the behavior in every version I tried ⏯ Playground Link https://www.typescriptlang.org/play?ts=5.3.0-dev.20230814&ssl=6&ssc=2&pln=1&pc=1#code/KYDwDg9...
Open Graph Description: 🔎 Search Terms widening return unique symbol 🕗 Version & Regression Information This is the behavior in every version I tried ⏯ Playground Link https://www.typescriptlang.org/play?ts=5.3.0-dev.2023...
X Description: 🔎 Search Terms widening return unique symbol 🕗 Version & Regression Information This is the behavior in every version I tried ⏯ Playground Link https://www.typescriptlang.org/play?ts=5.3.0-dev....
Opengraph URL: https://github.com/microsoft/TypeScript/issues/55361
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Explicitly annotated unique symbols are widened in return positions","articleBody":"### 🔎 Search Terms\r\n\r\nwidening return unique symbol\r\n\r\n### 🕗 Version & Regression Information\r\n\r\n- This is the behavior in every version I tried\r\n\r\n\r\n\r\n### ⏯ Playground Link\r\n\r\nhttps://www.typescriptlang.org/play?ts=5.3.0-dev.20230814&ssl=6&ssc=2&pln=1&pc=1#code/KYDwDg9gTgLgBAYwgOwM7xsdcC8cDKAngLYBGEANgBQCUAUHaJLHAGYCuyCMAlim8lpwA3nTjjEKbAEMKPaagBccGITDAIrFVnh5M6ANxiJUYDHZRkcWfNR0AvkA\r\n\r\n### 💻 Code\r\n\r\n```ts\r\nexport const test = Symbol()\r\n\r\nexport function fn() {\r\n const alias: typeof test = test;\r\n return alias\r\n}\r\n```\r\n\r\n\r\n### 🙁 Actual behavior\r\n\r\nthis declaration file is emitted:\r\n```ts\r\nexport declare const test: unique symbol;\r\nexport declare function fn(): symbol;\r\n```\r\n\r\n### 🙂 Expected behavior\r\n\r\nthis declaration file to be emitted:\r\n```ts\r\nexport declare const test: unique symbol;\r\nexport declare function fn(): typeof test;\r\n```\r\n\r\n### Additional information\r\n\r\n`getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded` calls `getWidenedLiteralLikeTypeForContextualType` and that calls `getWidenedUniqueESSymbolType` when there is no contextual type provided.\r\n\r\nsome issues that are (partially~) related:\r\nhttps://github.com/microsoft/TypeScript/issues/32242\r\nhttps://github.com/microsoft/TypeScript/issues/35896#issuecomment-569466046\r\nhttps://github.com/microsoft/TypeScript/issues/36876 ","author":{"url":"https://github.com/Andarist","@type":"Person","name":"Andarist"},"datePublished":"2023-08-14T09:50:26Z","url":"https://github.com/microsoft/TypeScript/issues/55361"}
| 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:5766466b-f281-2644-0cbb-11bfb3127a51 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D86E:163142:7D877D:B0314C:6B0481B8 |
| html-safe-nonce | b9dceb43247c4fe84d5f983bdc8948a293b66b4c1c569363888d652f7009a11d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEODZFOjE2MzE0Mjo3RDg3N0Q6QjAzMTRDOjZCMDQ4MUI4IiwidmlzaXRvcl9pZCI6IjMwOTgyODk2NDU2Mjk1MDU5NzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 73f5a67883a2d1a0e2079d16ae14ba854fbc771e6023185d798d502f454c14e8 |
| hovercard-subject-tag | issue:1849425228 |
| 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/55361/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e0744b0152f5151d6ac44a3f5ae66df268ad239a3c28ff5522bec7f5260212fd/microsoft/TypeScript/issues/55361 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e0744b0152f5151d6ac44a3f5ae66df268ad239a3c28ff5522bec7f5260212fd/microsoft/TypeScript/issues/55361 |
| og:image:alt | 🔎 Search Terms widening return unique symbol 🕗 Version & Regression Information This is the behavior in every version I tried ⏯ Playground Link https://www.typescriptlang.org/play?ts=5.3.0-dev.2023... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Andarist |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0366ddfb372682a32e92a5d86155cb08fa83e5bbe79953a968789f2f7e24c511 |
| 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 | ed3f2e01f6b7672780c586c8af0e72726374d7b6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width