Title: satisfies support in JSDoc · Issue #51086 · microsoft/TypeScript · GitHub
Open Graph Title: satisfies support in JSDoc · Issue #51086 · microsoft/TypeScript
X Title: satisfies support in JSDoc · Issue #51086 · microsoft/TypeScript
Description: Suggestion 🔍 Search Terms satisfies, jsdoc ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change in existing TypeScript/JavaScript code This wouldn't change the runtime behavior of existing JavaSc...
Open Graph Description: Suggestion 🔍 Search Terms satisfies, jsdoc ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change in existing TypeScript/JavaScript code This wouldn't change...
X Description: Suggestion 🔍 Search Terms satisfies, jsdoc ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change in existing TypeScript/JavaScript code This wouldn'...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/51086
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"satisfies support in JSDoc","articleBody":"# Suggestion\r\n\u003c!--\r\n Please fill in each section completely. Thank you!\r\n-->\r\n\r\n## 🔍 Search Terms\r\nsatisfies, jsdoc\r\n\r\n## ✅ Viability 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, 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## ⭐ Suggestion\r\n\r\nIt would be fantastic to have `satisfies` support in jsdoc. This was previously discussed in the [satisfies PR](https://github.com/microsoft/TypeScript/pull/46827#issuecomment-1256844006) (with the suggestion to open a separate tracking issue) and in the [8/17/2022 Design Meeting](https://github.com/microsoft/TypeScript/issues/50522).\r\n\r\nThere was a discussion about using `/** @type {satisfies T} */`, but I would love to see TS be more opinionated on this and go for `/** @satisfies {T} */`.\r\n\r\nTwo main reasons:\r\n- more straightforward in intent and keeps already-lengthy jsdoc lines from getting even longer\r\n- allows the same functionality as ts files if (for some reason) you really want to include a type annotation and a `satisfies` clause. There aren't great reasons to do this, but the fewer functionality differences between ts and jsdoc the better.\r\n\r\nThe design meeting mentioned:\r\n\r\n> We try not to add new tags that aren't doc'd in the usejsdoc site.\r\n> Ship has sailed with TS-specific syntax in JSDoc, right?\r\n\r\nBut: unknown tags are common in the wild and `jsdoc` ([the utility](https://www.npmjs.com/package/jsdoc)) has `allowUnknownTags` set by default, so `@satisfies` information isn't included in the generated docs, but it also doesn't cause any errors. Parser-wise, it should also be relatively easy to support in the future, if there's a desire.\r\n\r\nThe syntax ship has definitely sailed, in contrast. TS hasn't added tags before AFAIK, but common TS-specific syntax is already often not parsed and causes errors (e.g. [`/** @type {{name: string}[]} */ const arr = [];`](https://github.com/jsdoc/jsdoc/issues/1628#issuecomment-584448870)).\r\n\r\n## 📃 Motivating Example\r\n\r\n```js\r\n/** @typedef {\"red\" | \"green\" | \"blue\"} Colors */\r\n\r\n/**\r\n * Ensure that we have exactly the keys from 'Colors'.\r\n * @satisfies {Record\u003cColors, unknown>}\r\n */\r\nconst favoriteColors = {\r\n red: 'yes',\r\n green: false,\r\n blue: 'kinda',\r\n platypus: false,\r\n// ~~~~~~~~ error - \"platypus\" was never listed in 'Colors'.\r\n}\r\n```\r\n\r\n## 💻 Use Cases\r\n\r\n`satisfies` in jsdoc!\r\n","author":{"url":"https://github.com/brendankenny","@type":"Person","name":"brendankenny"},"datePublished":"2022-10-06T18:37:36Z","url":"https://github.com/microsoft/TypeScript/issues/51086"}
| 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:53838488-55ca-d0af-f96e-d69dcf1e1fdc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E4D4:B53AF:2388A8F:2F4E98D:6B019438 |
| html-safe-nonce | f64552a998278bb97fd1b63122b63155926d23985aaf6270dd68363ce73dd6e9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNEQ0OkI1M0FGOjIzODhBOEY6MkY0RTk4RDo2QjAxOTQzOCIsInZpc2l0b3JfaWQiOiI3NTk0MTY4MDU1NjcyOTY4MjQ4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 5daf09f049115b872906fe01a90f74eed0c9e32edbb9e8889439280cb7e6d4f9 |
| hovercard-subject-tag | issue:1400136841 |
| 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/51086/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4a097a64c5709d394800393f272df01d632edf349ecdfbf0a3e4b8d815bd1d4c/microsoft/TypeScript/issues/51086 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4a097a64c5709d394800393f272df01d632edf349ecdfbf0a3e4b8d815bd1d4c/microsoft/TypeScript/issues/51086 |
| og:image:alt | Suggestion 🔍 Search Terms satisfies, jsdoc ✅ Viability Checklist My suggestion meets these guidelines: This wouldn't be a breaking change in existing TypeScript/JavaScript code This wouldn't change... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | brendankenny |
| 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