Title: Using "implements" causes an issue with string literal types. "extends" does not. · Issue #10071 · microsoft/TypeScript · GitHub
Open Graph Title: Using "implements" causes an issue with string literal types. "extends" does not. · Issue #10071 · microsoft/TypeScript
X Title: Using "implements" causes an issue with string literal types. "extends" does not. · Issue #10071 · microsoft/TypeScript
Description: TypeScript Version: nightly (2.0.0-dev.201xxxxx) Relevant StackOverflow discussion Playground Kudos to Nitzan Tomer (@nitzantomer) for looking into this Code // This is defined in a d.ts file. class Test { someObj: { someString: 'this'|'...
Open Graph Description: TypeScript Version: nightly (2.0.0-dev.201xxxxx) Relevant StackOverflow discussion Playground Kudos to Nitzan Tomer (@nitzantomer) for looking into this Code // This is defined in a d.ts file. clas...
X Description: TypeScript Version: nightly (2.0.0-dev.201xxxxx) Relevant StackOverflow discussion Playground Kudos to Nitzan Tomer (@nitzantomer) for looking into this Code // This is defined in a d.ts file. clas...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/10071
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Using \"implements\" causes an issue with string literal types. \"extends\" does not.","articleBody":"\u003c!-- BUGS: Please use this template. -->\n\n\u003c!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->\n\n\u003c!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->\n\n**TypeScript Version:** nightly (2.0.0-dev.201xxxxx)\n\n**[Relevant StackOverflow discussion](http://stackoverflow.com/questions/38687670/class-implements-another-class-getting-errors-looking-for-clarification)** \n\n**[Playground](https://www.typescriptlang.org/play/#src=class%20Test%20%7B%0D%0A%09someObj%3A%20%7B%0D%0A%09%09someString%3A%20'this'%7C'that'%7C'the%20other'%0D%0A%09%7D%3B%0D%0A%7D%0D%0A%0D%0Aclass%20Test2%20implements%20Test%20%7B%0D%0A%09someObj%20%3D%20%7B%0D%0A%09%09someString%3A%20'this'%0D%0A%09%7D%0D%0A%7D)**\n\nKudos to @nitzantomer for looking into this\n\n**Code**\n\n``` ts\n// This is defined in a d.ts file. \nclass Test {\n someObj: {\n someString: 'this'|'that'|'the other'\n };\n}\n\n// This is me actually using the class.\nclass Test2 implements Test {\n someObj = {\n someString: 'this'\n }\n}\n```\n\n**Expected behavior:**\nNo error thrown. Using literal `'this'` as the value for `someObj.someString` correctly implements class.\n\n**Actual behavior:** \nError thrown.\n\n```\nClass 'Test2' incorrectly implements interface 'Test'.\n Types of property 'someObj' are incompatible.\n Type '{ someString: string; }' is not assignable to type '{ someString: \"this\" | \"that\" | \"the other\"; }'.\n Types of property 'someString' are incompatible.\n Type 'string' is not assignable to type '\"this\" | \"that\" | \"the other\"'.\n Type 'string' is not assignable to type '\"the other\"'.\n```\n","author":{"url":"https://github.com/dsifford","@type":"Person","name":"dsifford"},"datePublished":"2016-08-01T17:57:00Z","url":"https://github.com/microsoft/TypeScript/issues/10071"}
| 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:4a9161d3-5326-b2cf-689b-e169a2f66dd4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B36A:DB09F:C24D58:F90806:6B010008 |
| html-safe-nonce | c6135f79ad8cb9b5c974c52eb660633c53ddf18b5b4705a06ecaad4f4fbad5b9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMzZBOkRCMDlGOkMyNEQ1ODpGOTA4MDY6NkIwMTAwMDgiLCJ2aXNpdG9yX2lkIjoiOTA3Nzk3MDUwNzg2ODk5NTU5MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4ef22e204ba08f87ad44ca54baa9ecb4cb730e2bb16a0dba78afeef7949d8e94 |
| hovercard-subject-tag | issue:168704049 |
| 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/10071/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8fef210408065988e61c22ddb27fc398dbb8135e86ff6960aaf7179f836e132b/microsoft/TypeScript/issues/10071 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8fef210408065988e61c22ddb27fc398dbb8135e86ff6960aaf7179f836e132b/microsoft/TypeScript/issues/10071 |
| og:image:alt | TypeScript Version: nightly (2.0.0-dev.201xxxxx) Relevant StackOverflow discussion Playground Kudos to Nitzan Tomer (@nitzantomer) for looking into this Code // This is defined in a d.ts file. clas... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dsifford |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| 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 | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width