Title: Negative constant enums return number when toString is called · Issue #54992 · microsoft/TypeScript · GitHub
Open Graph Title: Negative constant enums return number when toString is called · Issue #54992 · microsoft/TypeScript
X Title: Negative constant enums return number when toString is called · Issue #54992 · microsoft/TypeScript
Description: ⏯ Playground Link https://www.typescriptlang.org/play?ts=5.1.6#code/MYewdgzgLgBApmArgWxgFTtAok1BvAKBmJgEEYBeGARgBoiSAhSmAWmoIF8CDRIQANnAB0AkAHMAFA2JQAngAc4IAGYwAylABOASzBSM2XMNIBKeiRjylq9Jig4UJ4VBCbd+yaYLfe4CIIiYlIyVorKau56BvaOyMKM5qHWEX...
Open Graph Description: ⏯ Playground Link https://www.typescriptlang.org/play?ts=5.1.6#code/MYewdgzgLgBApmArgWxgFTtAok1BvAKBmJgEEYBeGARgBoiSAhSmAWmoIF8CDRIQANnAB0AkAHMAFA2JQAngAc4IAGYwAylABOASzBSM2XMNIBKeiRjylq9Jig4UJ4VBC...
X Description: ⏯ Playground Link https://www.typescriptlang.org/play?ts=5.1.6#code/MYewdgzgLgBApmArgWxgFTtAok1BvAKBmJgEEYBeGARgBoiSAhSmAWmoIF8CDRIQANnAB0AkAHMAFA2JQAngAc4IAGYwAylABOASzBSM2XMNIBKeiRjylq9Jig4UJ4VBC...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/54992
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Negative constant enums return number when toString is called","articleBody":"### ⏯ Playground Link\r\n\r\nhttps://www.typescriptlang.org/play?ts=5.1.6#code/MYewdgzgLgBApmArgWxgFTtAok1BvAKBmJgEEYBeGARgBoiSAhSmAWmoIF8CDRIQANnAB0AkAHMAFA2JQAngAc4IAGYwAylABOASzBSM2XMNIBKeiRjylq9Jig4UJ4VBCbd+yaYLfe4CIIiYlIyVorKau56BvaOyMKM5qHWEXZGTowubtrRXj5AA\r\n\r\n### 💻 Code\r\n\r\n```ts\r\nconst enum TestEnum {\r\n A = 1,\r\n B = -1\r\n}\r\n\r\n// \"string\", \"string\" \r\nconsole.log(\r\n typeof String(TestEnum.A),\r\n typeof TestEnum.A.toString()\r\n)\r\n\r\n// \"string\", \"number\" \r\nconsole.log(\r\n typeof String(TestEnum.B),\r\n typeof TestEnum.B.toString()\r\n)\r\n```\r\n\r\n### 🙁 Actual behavior\r\n\r\nConstant enums which use negative numbers will return type of `number` when `.toString()` is called.\r\n\r\n### 🙂 Expected behavior\r\n\r\nA `string` type should be returned","author":{"url":"https://github.com/DustinBrett","@type":"Person","name":"DustinBrett"},"datePublished":"2023-07-12T17:17:33Z","url":"https://github.com/microsoft/TypeScript/issues/54992"}
| 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:f8bf1d00-451d-5225-63a0-ea4844b22616 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E844:928E2:1C1EC40:258028A:6B0163C1 |
| html-safe-nonce | ff04e47541f80c54d58833e71410fbbc3518637402db2b1e8ca8d5f91bc65637 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFODQ0OjkyOEUyOjFDMUVDNDA6MjU4MDI4QTo2QjAxNjNDMSIsInZpc2l0b3JfaWQiOiI2ODc1NjY0NTg3MzM3ODUxODQxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 64dd924e8eb80523d411b4729382886f302dd3e2404ae66c57e133fdcf3fbd05 |
| hovercard-subject-tag | issue:1801415680 |
| 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/54992/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cebca4b911300c84ceb1994434c24fade23d5aa9a613b8b431aa1add1ae6c532/microsoft/TypeScript/issues/54992 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cebca4b911300c84ceb1994434c24fade23d5aa9a613b8b431aa1add1ae6c532/microsoft/TypeScript/issues/54992 |
| og:image:alt | ⏯ Playground Link https://www.typescriptlang.org/play?ts=5.1.6#code/MYewdgzgLgBApmArgWxgFTtAok1BvAKBmJgEEYBeGARgBoiSAhSmAWmoIF8CDRIQANnAB0AkAHMAFA2JQAngAc4IAGYwAylABOASzBSM2XMNIBKeiRjylq9Jig4UJ4VBC... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DustinBrett |
| 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