Title: Intersection with mapped never type allows incompatible optional assignments · Issue #19927 · microsoft/TypeScript · GitHub
Open Graph Title: Intersection with mapped never type allows incompatible optional assignments · Issue #19927 · microsoft/TypeScript
X Title: Intersection with mapped never type allows incompatible optional assignments · Issue #19927 · microsoft/TypeScript
Description: TypeScript Version: 2.7.0-dev.20171110 Code declare const a: {z: string} & {[K in never]: string} const b: {z?: number} = a Expected behavior: Compile error on the second line because {z?: number} is incompatible with {z: string} Actual ...
Open Graph Description: TypeScript Version: 2.7.0-dev.20171110 Code declare const a: {z: string} & {[K in never]: string} const b: {z?: number} = a Expected behavior: Compile error on the second line because {z?: number} ...
X Description: TypeScript Version: 2.7.0-dev.20171110 Code declare const a: {z: string} & {[K in never]: string} const b: {z?: number} = a Expected behavior: Compile error on the second line because {z?: numb...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/19927
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Intersection with mapped never type allows incompatible optional assignments","articleBody":"\u003c!-- BUGS: Please use this template. -->\r\n\u003c!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->\r\n\u003c!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->\r\n\r\n\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** 2.7.0-dev.20171110\r\n\r\n**Code**\r\n\r\n```ts\r\ndeclare const a: {z: string} & {[K in never]: string} \r\nconst b: {z?: number} = a\r\n```\r\n\r\n**Expected behavior:**\r\nCompile error on the second line because `{z?: number}` is incompatible with `{z: string}`\r\n\r\n**Actual behavior:**\r\nNo Error\r\n\r\nObviously the code above is nonsensical but I spun this out of a special case in #19869 since that one ended up being about generic function inferences and I realized this is something different.\r\n\r\nSome more code examples that make me think my example should have a compile error: \r\n\r\n```ts\r\ndeclare const a2: {z: string} & {[K in never]: string}\r\nconst b2: {z: number} = a2 \r\n// TS2322: Type '{ z: string; } & {}' is not assignable to type '{ z: number; }'.\r\n\r\ndeclare const a3: {z: string} & {}\r\nconst b3: {z?: number} = a3 \r\n// TS2322: Type '{ z: string; }' is not assignable to type '{ z?: number | undefined; }'.\r\n\r\ndeclare const a4: {z: string, y: string} & {[K in never]: string}\r\nconst b4: {z?: number, y: string} = a4 \r\n// TS2322: Type '{ z: string; y: string; } & {}' is not assignable to type '{ z?: number | undefined; y: string; }'.\r\n```","author":{"url":"https://github.com/kpdonn","@type":"Person","name":"kpdonn"},"datePublished":"2017-11-10T21:20:12Z","url":"https://github.com/microsoft/TypeScript/issues/19927"}
| 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:413c948a-f534-b1da-c7ca-199418a64203 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C19E:F7C4C:99B1A4:CF9CCD:6B00EBE2 |
| html-safe-nonce | 264cb83491f92748eb13bb894327e7bd7f952dc8f63b0b86b7739b7602312964 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMTlFOkY3QzRDOjk5QjFBNDpDRjlDQ0Q6NkIwMEVCRTIiLCJ2aXNpdG9yX2lkIjoiMTc1NjAxODcxMzg2NzM4MTczMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 97e2bc859879cc826ab14295b5fad5d78b60a050a733edd01e509556778a6196 |
| hovercard-subject-tag | issue:273063027 |
| 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/19927/issue_layout |
| twitter:image | https://opengraph.githubassets.com/665871915776fb762f5ba21df40e2293ebcba57ed7353cafca1b72aafe446e2a/microsoft/TypeScript/issues/19927 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/665871915776fb762f5ba21df40e2293ebcba57ed7353cafca1b72aafe446e2a/microsoft/TypeScript/issues/19927 |
| og:image:alt | TypeScript Version: 2.7.0-dev.20171110 Code declare const a: {z: string} & {[K in never]: string} const b: {z?: number} = a Expected behavior: Compile error on the second line because {z?: number} ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kpdonn |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width