Title: `unique symbol` type lost after property is extracted from an object · Issue #43657 · microsoft/TypeScript · GitHub
Open Graph Title: `unique symbol` type lost after property is extracted from an object · Issue #43657 · microsoft/TypeScript
X Title: `unique symbol` type lost after property is extracted from an object · Issue #43657 · microsoft/TypeScript
Description: Bug Report Found while working on nodejs/node#38198 🔎 Search Terms unique symbol object ⏯ Playground Link Playground link with relevant code 💻 Code declare const kSomeConstant: unique symbol; declare function test(value: typeof kSomeCons...
Open Graph Description: Bug Report Found while working on nodejs/node#38198 🔎 Search Terms unique symbol object ⏯ Playground Link Playground link with relevant code 💻 Code declare const kSomeConstant: unique symbol; decla...
X Description: Bug Report Found while working on nodejs/node#38198 🔎 Search Terms unique symbol object ⏯ Playground Link Playground link with relevant code 💻 Code declare const kSomeConstant: unique symbol; decla...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/43657
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`unique symbol` type lost after property is extracted from an object","articleBody":"# Bug Report\r\n\r\nFound while working on https://github.com/nodejs/node/pull/38198\r\n\r\n### 🔎 Search Terms\r\n\r\nunique symbol object\r\n\r\n### ⏯ Playground Link\r\n\r\n[Playground link with relevant code](https://www.typescriptlang.org/play?#code/CYUwxgNghgTiAEYD2A7AzgF3gawMpIFsQBhVTKFDALngFcUBLAR1oTQE8CAjJCAbgCwAKFCRYCAGb0wGBqngYQmABQA3KBFY0M7AA4gkEnPiKl0GChgCUNVUgbBBI8NDjwpKGXJTwA5iAwAUQAPXSQYDDRlG3gAb2F4RONCEjILSm09AyM8FLNySickhSVqBSzDEswnAF9hYQB6ACoEpORzeBBQmnihYuLc0zTLTP1KwdTzSyL+xMVMUeyqjBnEuqEmhuF2zE7Q+ABePwCQsIioq3qhBob4ZV0YJH0I9itkoamM8rGck0mCjDCLq6AB08wwymBIIm+XS1iuN0QaSRnzKHG4vG2yJ2cMOe1BMOGhSBoTBpWUOMsVicQA)\r\n\r\n### 💻 Code\r\n\r\n```ts\r\ndeclare const kSomeConstant: unique symbol;\r\ndeclare function test(value: typeof kSomeConstant): void;\r\ndeclare function getExports(): {\r\n kSomeConstant: typeof kSomeConstant;\r\n test: typeof test;\r\n}\r\n\r\n/*\r\n const exp: {\r\n kSomeConstant: typeof kSomeConstant;\r\n test: typeof test;\r\n }\r\n*/\r\nconst exp = getExports()\r\n\r\n// (property) kSomeConstant: typeof kSomeConstant\r\nexp.test(exp.kSomeConstant)\r\n\r\n// const constant: symbol\r\nconst constant = exp.kSomeConstant;\r\nexp.test(constant);\r\n```\r\n\r\n### 🙁 Actual behavior\r\n\r\n`exp.test(constant)` is an error, because `constant`'s type is inferred to `symbol` instead of `typeof kSomeConstant`.\r\n\r\n### 🙂 Expected behavior\r\n\r\nThe extracted variable should have the same type","author":{"url":"https://github.com/targos","@type":"Person","name":"targos"},"datePublished":"2021-04-13T17:20:48Z","url":"https://github.com/microsoft/TypeScript/issues/43657"}
| 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:be497465-f5db-68ab-3e2d-7e1b83b47b62 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D3F0:367411:96B9EF:CDEA06:6B04811C |
| html-safe-nonce | 3d0d571e5fbdee085443b6db539c421dad7d9f5a2dc2831eb875f2a49387b07a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEM0YwOjM2NzQxMTo5NkI5RUY6Q0RFQTA2OjZCMDQ4MTFDIiwidmlzaXRvcl9pZCI6IjIwOTAyMzY4MTY2ODYwODg0NzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e8a85ecdd2e7e297ef5d3df367b92595f76c3d90478b77aa09ba5a29fdf530ac |
| hovercard-subject-tag | issue:857168778 |
| 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/43657/issue_layout |
| twitter:image | https://opengraph.githubassets.com/85d530774be4df5d442b4479b5e140c71fb97b913f21d02d6e1640ad18435ed6/microsoft/TypeScript/issues/43657 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/85d530774be4df5d442b4479b5e140c71fb97b913f21d02d6e1640ad18435ed6/microsoft/TypeScript/issues/43657 |
| og:image:alt | Bug Report Found while working on nodejs/node#38198 🔎 Search Terms unique symbol object ⏯ Playground Link Playground link with relevant code 💻 Code declare const kSomeConstant: unique symbol; decla... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | targos |
| 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