Title: False positive error report for enum and class instance type missing index signature, thus not assignable to object type with `unknown` values. · Issue #30977 · microsoft/TypeScript · GitHub
Open Graph Title: False positive error report for enum and class instance type missing index signature, thus not assignable to object type with `unknown` values. · Issue #30977 · microsoft/TypeScript
X Title: False positive error report for enum and class instance type missing index signature, thus not assignable to object type with `unknown` values. · Issue #30977 · microsoft/TypeScript
Description: TypeScript Version: 3.5.0-dev.20190410, (v3.4.3 doesn't have this bug) Search Terms: enum, class, assignable, index signature Code enum Enum { A } const e0: { [key: string]: any } = Enum; // ok const e1: { [key: string]: unknown } = Enum...
Open Graph Description: TypeScript Version: 3.5.0-dev.20190410, (v3.4.3 doesn't have this bug) Search Terms: enum, class, assignable, index signature Code enum Enum { A } const e0: { [key: string]: any } = Enum; // ok con...
X Description: TypeScript Version: 3.5.0-dev.20190410, (v3.4.3 doesn't have this bug) Search Terms: enum, class, assignable, index signature Code enum Enum { A } const e0: { [key: string]: any } = Enum; // ok...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/30977
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"False positive error report for enum and class instance type missing index signature, thus not assignable to object type with `unknown` values.","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. Even if you think you've found a *bug*, please read the FAQ first, especially the Common \"Bugs\" That Aren't Bugs section!\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\nPlease fill in the *entire* template below.\r\n-->\r\n\r\n\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** `3.5.0-dev.20190410`, (`v3.4.3` doesn't have this bug)\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:**\r\nenum, class, assignable, index signature\r\n\r\n\r\n**Code**\r\n\r\n```ts\r\nenum Enum { A }\r\n\r\nconst e0: { [key: string]: any } = Enum; // ok\r\nconst e1: { [key: string]: unknown } = Enum; // produces an unexpected error report\r\n\r\n//\r\n\r\nconst obj = { A: 0 };\r\n\r\nconst o0: { [key: string]: any } = obj; // ok\r\nconst o1: { [key: string]: unknown } = obj; // ok\r\n\r\n// \r\n\r\nclass Class {}\r\n\r\nexport const cl0: { [key: string]: any } = new Class; // ok\r\nexport const cl1: { [key: string]: unknown } = new Class; // produces an unexpected error report\r\n```\r\n\r\n**Expected behavior:**\r\nThis code should compile with no errors.\r\n\r\n**Actual behavior:**\r\nError near the definition of `e1` and `cl1`: \r\n\r\n```\r\nType 'typeof Enum/Class' is not assignable to type '{ [key: string]: unknown; }'.\r\nIndex signature is missing in type 'typeof Enum/Class'.\r\n```\r\n\r\n\r\n**Playground Link:**\r\nThis works well in the playground as it uses the stable version of `tsc`, but this bug appears in dev build. [Klick me](https://www.typescriptlang.org/play/index.html#src=enum%20Enum%20%7B%20A%20%7D%0D%0A%0D%0Aconst%20e0%3A%20%7B%20%5Bkey%3A%20string%5D%3A%20any%20%20%20%20%20%7D%20%3D%20Enum%3B%20%20%20%20%20%20%2F%2F%20ok%0D%0Aconst%20e1%3A%20%7B%20%5Bkey%3A%20string%5D%3A%20unknown%20%7D%20%3D%20Enum%3B%20%2F%2F%20produces%20an%20unexpected%20error%20report%0D%0A%0D%0A%2F%2F%0D%0A%0D%0Aconst%20obj%20%3D%20%7B%20A%3A%200%20%7D%3B%0D%0A%0D%0Aconst%20o0%3A%20%7B%20%5Bkey%3A%20string%5D%3A%20any%20%20%20%20%20%7D%20%3D%20obj%3B%20%2F%2F%20ok%0D%0Aconst%20o1%3A%20%7B%20%5Bkey%3A%20string%5D%3A%20unknown%20%7D%20%3D%20obj%3B%20%2F%2F%20ok%0D%0A%0D%0A%2F%2F%20%0D%0A%0D%0Aclass%20User%20%7B%7D%0D%0A%0D%0Aexport%20const%20cl0%3A%20%7B%20%5Bkey%3A%20string%5D%3A%20any%20%20%20%20%20%7D%20%3D%20new%20User%3B%20%2F%2F%20ok%0D%0Aexport%20const%20cl1%3A%20%7B%20%5Bkey%3A%20string%5D%3A%20unknown%20%7D%20%3D%20new%20User%3B%20%2F%2F%20produces%20an%20unexpected%20error%20report).\r\n\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? -->\r\nNone.","author":{"url":"https://github.com/Veetaha","@type":"Person","name":"Veetaha"},"datePublished":"2019-04-16T22:29:30Z","url":"https://github.com/microsoft/TypeScript/issues/30977"}
| 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:b9679bae-8ded-a01d-12d4-5e2b9277ad76 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EDF2:2E124E:5B1A42:75FCEB:6B00DE1F |
| html-safe-nonce | e13e5dbe2633dd5188821e8059ff0ab7dba2f1f436b0b02e3642df5879d44a39 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFREYyOjJFMTI0RTo1QjFBNDI6NzVGQ0VCOjZCMDBERTFGIiwidmlzaXRvcl9pZCI6IjYyNDQ1MDA3NzM2MTU0OTI2MzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d938da8a2a60a86757a3c6576ef9ada47e3380bb750ae862945bfdf88f4673cf |
| hovercard-subject-tag | issue:434013134 |
| 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/30977/issue_layout |
| twitter:image | https://opengraph.githubassets.com/596d1f0a493d94c733c1bf118f9191cb82c8f901abfdad7b12773f559576f1c9/microsoft/TypeScript/issues/30977 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/596d1f0a493d94c733c1bf118f9191cb82c8f901abfdad7b12773f559576f1c9/microsoft/TypeScript/issues/30977 |
| og:image:alt | TypeScript Version: 3.5.0-dev.20190410, (v3.4.3 doesn't have this bug) Search Terms: enum, class, assignable, index signature Code enum Enum { A } const e0: { [key: string]: any } = Enum; // ok con... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Veetaha |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| 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 | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width