Title: const assertions in JSDoc · Issue #30445 · microsoft/TypeScript · GitHub
Open Graph Title: const assertions in JSDoc · Issue #30445 · microsoft/TypeScript
X Title: const assertions in JSDoc · Issue #30445 · microsoft/TypeScript
Description: Search Terms const jsdoc Suggestion v3.4 added support for as const to mark a literal expression as immutable and disable type widening. This feature uses the TypeScript type assertion syntax {} as const or
Open Graph Description: Search Terms const jsdoc Suggestion v3.4 added support for as const to mark a literal expression as immutable and disable type widening. This feature uses the TypeScript type assertion syntax {} as...
X Description: Search Terms const jsdoc Suggestion v3.4 added support for as const to mark a literal expression as immutable and disable type widening. This feature uses the TypeScript type assertion syntax {} as...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/30445
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"const assertions in JSDoc","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Please read the FAQ first, especially the \"Common Feature Requests\" section.\r\n\r\n-->\r\n\r\n## Search Terms\r\n\r\nconst jsdoc\r\n\r\n## Suggestion\r\n\r\nv3.4 added support for `as const` to mark a literal expression as immutable and disable type widening. This feature uses the TypeScript type assertion syntax `{} as const` or `\u003cconst>{}`.\r\n\r\nIn JS files you can use JSDoc to do type assertions: `/** @type {T} */(v)`\r\nUnfortunately that doesn't work with const assertions.\r\n\r\n```js\r\n// @ts-check\r\nconst foo = /** @type {const} */([1]); // Error: cannot find name 'const'\r\n```\r\n\r\nThis proposes adding support for `/** @type {const} */([1])`.\r\n\r\nAn alternative could be `/** @const */([1])`.\r\n\r\n## Use Cases\r\n\r\nThe same as for const assertions in TS files.\r\n\r\n## Checklist\r\n\r\nMy suggestion meets these guidelines:\r\n\r\n* [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code\r\n* [x] This wouldn't change the runtime behavior of existing JavaScript code\r\n* [x] This could be implemented without emitting different JS based on the types of the expressions\r\n* [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)\r\n* [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).\r\n\r\n","author":{"url":"https://github.com/ajafff","@type":"Person","name":"ajafff"},"datePublished":"2019-03-16T11:23:58Z","url":"https://github.com/microsoft/TypeScript/issues/30445"}
| 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:f627052e-bb32-dbde-fc3f-34fda5ec0fcf |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B8BC:A99C2:C180C1:F9DEF5:6B00EB68 |
| html-safe-nonce | 7061dab4c6aa691ba74855d7811cb65355bc50fdabb9bc57e652cc07f5f07fc6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOEJDOkE5OUMyOkMxODBDMTpGOURFRjU6NkIwMEVCNjgiLCJ2aXNpdG9yX2lkIjoiMzY3NDc1OTk0OTkzOTk2MDY4MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d2c20e7c3f2af9d3fce450fb62a6ab6ee2a58ce4a4da81d304ed5feef5e1c152 |
| hovercard-subject-tag | issue:421797165 |
| 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/30445/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fd3c0a86aa931faeb5c702b5e787f014a1c322c027651e49c53a26dc151c0333/microsoft/TypeScript/issues/30445 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fd3c0a86aa931faeb5c702b5e787f014a1c322c027651e49c53a26dc151c0333/microsoft/TypeScript/issues/30445 |
| og:image:alt | Search Terms const jsdoc Suggestion v3.4 added support for as const to mark a literal expression as immutable and disable type widening. This feature uses the TypeScript type assertion syntax {} as... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ajafff |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width