Title: cannot use unique symbol as object key when generating declarations from JS · Issue #37022 · microsoft/TypeScript · GitHub
Open Graph Title: cannot use unique symbol as object key when generating declarations from JS · Issue #37022 · microsoft/TypeScript
X Title: cannot use unique symbol as object key when generating declarations from JS · Issue #37022 · microsoft/TypeScript
Description: TypeScript Version: 3.9.0-dev.20200225 Also tried in 3.8.2. Search Terms: js symbol declaration ts9006 Code See gist https://gist.github.com/boneskull/93484ca75cef49c11c69b1d416153bc4 Additionally, a.d.ts is created successfully: export ...
Open Graph Description: TypeScript Version: 3.9.0-dev.20200225 Also tried in 3.8.2. Search Terms: js symbol declaration ts9006 Code See gist https://gist.github.com/boneskull/93484ca75cef49c11c69b1d416153bc4 Additionally,...
X Description: TypeScript Version: 3.9.0-dev.20200225 Also tried in 3.8.2. Search Terms: js symbol declaration ts9006 Code See gist https://gist.github.com/boneskull/93484ca75cef49c11c69b1d416153bc4 Additionally,...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/37022
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"cannot use unique symbol as object key when generating declarations from JS","articleBody":"\u003c!--\r\nPlease try to reproduce the issue with the latest published version. It may have already been fixed.\r\nFor npm: `typescript@next`\r\nThis is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly\r\n-->\r\n**TypeScript Version:** 3.9.0-dev.20200225\r\n\r\nAlso tried in 3.8.2.\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** js symbol declaration ts9006\r\n\r\n**Code**\r\n\r\nSee gist https://gist.github.com/boneskull/93484ca75cef49c11c69b1d416153bc4\r\n\r\nAdditionally, `a.d.ts` is created successfully:\r\n\r\n```ts\r\nexport const kSymbol: unique symbol;\r\nexport type WithSymbol = {\r\n [kSymbol]: true;\r\n};\r\n```\r\n\r\nI could not find a workaround (though there may be one!), since the `unique symbol` syntax is seemingly unavailable to JavaScript; it's not allowed in a `@type` docstring attribute. A workaround like this was shown in #36976.\r\n\r\n**Expected behavior:**\r\n\r\n`b.d.ts` is generated without error.\r\n\r\n**Actual behavior:**\r\n\r\n`kSymbol` is considered private, `b.d.ts` is not generated, and an error is emitted:\r\n\r\n```\r\nb.js:1:1 - error TS9006: Declaration emit for this file requires using private name 'kSymbol' from module '\"/path/to/a\"'. An explicit type annotation may unblock declaration emit.\r\n\r\n1 import {kSymbol} from './a';\r\n ~~~~~~\r\n\r\n\r\nFound 1 error.\r\n```\r\n\r\nNote that `kSymbol` is explicitly exported, and is not \"private\".\r\n\r\n**Playground Link:** (playgrounds don't support generating declarations)\r\n\r\n**Related Issues:** This may be related to #36976.\r\n","author":{"url":"https://github.com/boneskull","@type":"Person","name":"boneskull"},"datePublished":"2020-02-25T19:42:04Z","url":"https://github.com/microsoft/TypeScript/issues/37022"}
| 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:f91d07d5-d1b3-78fe-2b22-ada843c8c5ec |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EBE4:1D20B7:29C69C2:34F8BAE:6B01D921 |
| html-safe-nonce | 70cfec91972471580837cf56e8547ab5330f6a8dac66b11f55e80db12e8d89b8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQkU0OjFEMjBCNzoyOUM2OUMyOjM0RjhCQUU6NkIwMUQ5MjEiLCJ2aXNpdG9yX2lkIjoiMTI1NTg3MTA2NTAzMzM5ODU2MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | dd5749333dc91aaf8c1732912fb5665a02014e99ea7ab34ca21ce512e76f7c3f |
| hovercard-subject-tag | issue:570789014 |
| 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/37022/issue_layout |
| twitter:image | https://opengraph.githubassets.com/07baa5edfba787828055f686f85d5cfa3c71ed480c4762b0cfa1eb5eeae43ed9/microsoft/TypeScript/issues/37022 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/07baa5edfba787828055f686f85d5cfa3c71ed480c4762b0cfa1eb5eeae43ed9/microsoft/TypeScript/issues/37022 |
| og:image:alt | TypeScript Version: 3.9.0-dev.20200225 Also tried in 3.8.2. Search Terms: js symbol declaration ts9006 Code See gist https://gist.github.com/boneskull/93484ca75cef49c11c69b1d416153bc4 Additionally,... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | boneskull |
| 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 |
Links:
Viewport: width=device-width