Title: JSDoc support for String array to Object key · Issue #45902 · microsoft/TypeScript · GitHub
Open Graph Title: JSDoc support for String array to Object key · Issue #45902 · microsoft/TypeScript
X Title: JSDoc support for String array to Object key · Issue #45902 · microsoft/TypeScript
Description: Suggestion 🔍 Search Terms List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback. ✅ Viability Checklist My suggestion meets these g...
Open Graph Description: Suggestion 🔍 Search Terms List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback. ✅ Viabili...
X Description: Suggestion 🔍 Search Terms List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback. ✅ Viabili...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/45902
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"JSDoc support for String array to Object key","articleBody":"# Suggestion\r\n\r\n\u003c!--\r\n Please fill in each section completely. Thank you!\r\n-->\r\n\r\n## 🔍 Search Terms\r\n\r\n\u003c!--\r\n 💡 Did you know? TypeScript has over 2,000 open suggestions!\r\n 🔎 Please search thoroughly before logging new feature requests as most common ideas already have a proposal in progress.\r\n The \"Common Feature Requests\" section of the FAQ lists many popular requests: https://github.com/Microsoft/TypeScript/wiki/FAQ#common-feature-requests\r\n\r\n Replace the text below:\r\n-->\r\n\r\nList of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback.\r\n\r\n## ✅ Viability Checklist\r\n\r\n\u003c!--\r\n Suggestions that don't meet all these criteria are very, very unlikely to be accepted.\r\n We always recommend reviewing the TypeScript design goals before investing time writing\r\n a proposal for ideas outside the scope of the project.\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, new syntax sugar for JS, 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\r\n## ⭐ Suggestion\r\n\r\nJSDoc support for String array to Object key\r\n\r\n## 📃 Motivating Example\r\n\r\n```javascript\r\n/**\r\n * @template T\r\n * @param {T[]} obj\r\n * @returns {Readonly\u003c{[T]: number}>}\r\n */\r\nfunction Flags(obj) {\r\n const _obj = {}\r\n _.forEach(obj, (key, index) => {\r\n _obj[key] = 1 \u003c\u003c index\r\n })\r\n return Object.freeze(_obj)\r\n}\r\n\r\nconst TEST = Flags([\r\n 'A',\r\n 'B',\r\n 'C',\r\n 'D'\r\n])\r\n\r\n// We want to\r\n\r\n// TEST.\r\n// -----------\r\n// | A |\r\n// | B |\r\n// | C |\r\n// | D |\r\n// -----------\r\n```\r\n\r\n## 💻 Use Cases\r\n\r\nIn the above example, I can use bit enumeration\r\n\r\n```javascript\r\n/**\r\n * @param {number} enums\r\n * @param {number} flags\r\n */\r\nfunction hasFlag(enums, flags) {\r\n return flags === (enums & flags)\r\n}\r\n\r\ncosnt test = TEST.A | TEST.C | TEST.D\r\n\r\nconsole.log(hasFlag(test, TEST.A)) // true\r\nconsole.log(hasFlag(test, TEST.B)) // false\r\nconsole.log(hasFlag(test, TEST.C)) // true\r\n\r\n```\r\n","author":{"url":"https://github.com/imba97","@type":"Person","name":"imba97"},"datePublished":"2021-09-16T04:02:31Z","url":"https://github.com/microsoft/TypeScript/issues/45902"}
| 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:b8236c74-b07a-2d67-8841-8c0c57819489 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AA18:1F7384:B7ED66:F496F8:6B00F083 |
| html-safe-nonce | 678834a81d5947ffc9ace6a4581581e92560557f710d93521b3e4bc9f3257ef3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQTE4OjFGNzM4NDpCN0VENjY6RjQ5NkY4OjZCMDBGMDgzIiwidmlzaXRvcl9pZCI6IjgwOTgyMDcyNzk4ODQ1OTUzMzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 802b195f1c997d3cec0a2743a1e6a215d775ba497bcf35eeb7c6d14a3f078337 |
| hovercard-subject-tag | issue:997744654 |
| 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/45902/issue_layout |
| twitter:image | https://opengraph.githubassets.com/da3b7cafb5bd992fe835704854136105091f03b146d9900d49da3d5d78639beb/microsoft/TypeScript/issues/45902 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/da3b7cafb5bd992fe835704854136105091f03b146d9900d49da3d5d78639beb/microsoft/TypeScript/issues/45902 |
| og:image:alt | Suggestion 🔍 Search Terms List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback. ✅ Viabili... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | imba97 |
| 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