Title: [Feature request] sort literals in .d.ts · Issue #32224 · microsoft/TypeScript · GitHub
Open Graph Title: [Feature request] sort literals in .d.ts · Issue #32224 · microsoft/TypeScript
X Title: [Feature request] sort literals in .d.ts · Issue #32224 · microsoft/TypeScript
Description: Search Terms Suggestion sort string literal in .d.ts Use Cases avoid string literal random change order when source code didn't change and make code history is more easy read in this issue thread string literal is mean => "a" | "c" | "b"...
Open Graph Description: Search Terms Suggestion sort string literal in .d.ts Use Cases avoid string literal random change order when source code didn't change and make code history is more easy read in this issue thread s...
X Description: Search Terms Suggestion sort string literal in .d.ts Use Cases avoid string literal random change order when source code didn't change and make code history is more easy read in this issue thre...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/32224
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Feature request] sort literals in .d.ts","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\n\u003c!-- List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily -->\r\n\r\n## Suggestion\r\n\r\n\u003c!-- A summary of what you'd like to see added or changed -->\r\n\r\nsort string literal in .d.ts\r\n\r\n## Use Cases\r\n\r\n\u003c!--\r\nWhat do you want to use this for?\r\nWhat shortcomings exist with current approaches?\r\n-->\r\n\r\navoid string literal random change order when source code didn't change\r\nand make code history is more easy read\r\n\r\nin this issue thread `string literal` is mean => `\"a\" | \"c\" | \"b\"`\r\n\r\nthis not only happen on `Record`, it has chance happen at all type is auto create by typescript emit with `string literal`\r\n\r\n## Examples\r\n\r\n\u003c!-- Show how this would be used and what the behavior would be -->\r\n\r\n> `\"a\" | \"c\" | \"b\"` is create by typesctipt emit and some time will random change order\r\n\r\n- https://github.com/bluelovers/cjk-convert/blob/1a0ba9f85e0bf7fe916158cc14a4ef87507106d9/lib/zh/table/table.ts#L1619-L1635\r\n- https://github.com/microsoft/TypeScript/issues/30328\r\n - https://github.com/bluelovers/novel-travis-test/commit/3b88745e187736797d9a30d4f4bbd927b0c6dd30#diff-3006c96d8657ccca5b9b3618a256314c\r\n - https://github.com/bluelovers/novel-travis-test/commit/d33c4a61602a8536d1414d36e027eb99845104f1#diff-3006c96d8657ccca5b9b3618a256314c\r\n - https://github.com/bluelovers/novel-travis-test/commit/2d749195c39ef386e6c4bad1ae6e19d007c03e93#diff-3006c96d8657ccca5b9b3618a256314c\r\n\r\n### current .d.ts output\r\n\r\n---\r\n\r\n```ts\r\nexport declare const table_plus: Record\u003c\"a\" | \"c\" | \"b\">\r\n// \"a\" | \"c\" | \"b\" is random change order\r\n```\r\n\r\n### in this request\r\n\r\n> sort ( use simple array.sort() ) it when output emit at `.d.ts`\r\n\r\n```ts\r\nexport declare const table_plus: Record\u003c\"a\" | \"b\" | \"c\">\r\n```\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* [ ] 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* [ ] 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*Maintainer's note* [@sandersn]: To implementers: When you implement this, be sure to sort other literal types too. Consider sorting other things, like symbol, by the order of their string representation.","author":{"url":"https://github.com/bluelovers","@type":"Person","name":"bluelovers"},"datePublished":"2019-07-02T23:21:34Z","url":"https://github.com/microsoft/TypeScript/issues/32224"}
| 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:104774de-cf5e-b104-828b-23802eb8147d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 82A4:DA744:2731C47:34C26BF:6B01BD06 |
| html-safe-nonce | 9ef94bf8203f42b0799aaa02bd7677d064c72368902cf3973295045ec183f2db |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MkE0OkRBNzQ0OjI3MzFDNDc6MzRDMjZCRjo2QjAxQkQwNiIsInZpc2l0b3JfaWQiOiI4NzcyMTQ5OTY4NjAyNTEyNjQ2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ea4e87bd50aaa321bc9ff60b54b788152be9a5a88768df93ed94b2d6bad6a293 |
| hovercard-subject-tag | issue:463476437 |
| 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/32224/issue_layout |
| twitter:image | https://opengraph.githubassets.com/32bd8caa768d302d717a60b2730b648b9a0f047fb1f8d1bb4b169347f788c020/microsoft/TypeScript/issues/32224 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/32bd8caa768d302d717a60b2730b648b9a0f047fb1f8d1bb4b169347f788c020/microsoft/TypeScript/issues/32224 |
| og:image:alt | Search Terms Suggestion sort string literal in .d.ts Use Cases avoid string literal random change order when source code didn't change and make code history is more easy read in this issue thread s... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bluelovers |
| 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