Title: Error "Object literal may only specify known properties" is not happening in all cases with intersection types · Issue #18075 · microsoft/TypeScript · GitHub
Open Graph Title: Error "Object literal may only specify known properties" is not happening in all cases with intersection types · Issue #18075 · microsoft/TypeScript
X Title: Error "Object literal may only specify known properties" is not happening in all cases with intersection types · Issue #18075 · microsoft/TypeScript
Description: TypeScript Version: 2.4.2 export type MyType = { id: number; } & { name: string; } & { photo: { id: number; } & { url: string; } } export let obj: MyType; export const photo: typeof obj.photo = { id: 1, url: '', xyz: 1 // Great! This cau...
Open Graph Description: TypeScript Version: 2.4.2 export type MyType = { id: number; } & { name: string; } & { photo: { id: number; } & { url: string; } } export let obj: MyType; export const photo: typeof obj.photo = { i...
X Description: TypeScript Version: 2.4.2 export type MyType = { id: number; } & { name: string; } & { photo: { id: number; } & { url: string; } } export let obj: MyType; export const photo: typeof obj...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/18075
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Error \"Object literal may only specify known properties\" is not happening in all cases with intersection types","articleBody":"**TypeScript Version:** 2.4.2\r\n\r\n```ts\r\nexport type MyType =\r\n\t{\r\n\t\tid: number;\r\n\t}\r\n\t&\r\n\t{\r\n\t\tname: string;\r\n\t}\r\n\t&\r\n\t{\r\n\t\tphoto:\r\n\t\t{\r\n\t\t\tid: number;\r\n\t\t}\r\n\t\t&\r\n\t\t{\r\n\t\t\turl: string;\r\n\t\t}\r\n\t}\r\n\r\n\r\nexport let obj: MyType;\r\n\r\nexport const photo: typeof obj.photo = {\r\n\tid: 1,\r\n\turl: '',\r\n\txyz: 1\t// Great! This causes an error!\r\n};\r\n\t\r\nexport const myInstance: MyType = {\r\n\tid: 1,\r\n\tname: '',\r\n\tphoto: {\r\n\t\tid: 1,\r\n\t\turl: '',\r\n\t\txyz: 2\t// Bug? This does not cause an error!!!\r\n\t}\r\n};\r\n```\r\n\r\n**Expected behavior:**\r\n\r\nI expect all attributions to `xyz` to give an error.\r\n\r\n**Actual behavior:**\r\n\r\nTypeScript is accepting one of the attributions to `xyz` (with value 2).","author":{"url":"https://github.com/asfernandes","@type":"Person","name":"asfernandes"},"datePublished":"2017-08-27T15:17:51Z","url":"https://github.com/microsoft/TypeScript/issues/18075"}
| 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:3216a61f-2ba5-4e53-44a4-e66c181c9542 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8CE0:3A159F:6C27A:8A0F3:6B00F25A |
| html-safe-nonce | 9d7b19edebc29cef37e617894bc303c735190ebb15b5c1edca78aec867f1029a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Q0UwOjNBMTU5Rjo2QzI3QTo4QTBGMzo2QjAwRjI1QSIsInZpc2l0b3JfaWQiOiI4MjQ2NTIyNTg5NDkzNjU0MTA2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | f922b9f22f1c7c12b5ce6eff7ad33323da52c0a7f6ff955b930bb89f283f5cf1 |
| hovercard-subject-tag | issue:253169964 |
| 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/18075/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fe4aeadcb43c56e696206074ec568d018b931fe5c6762dba64c24f7708dda2da/microsoft/TypeScript/issues/18075 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fe4aeadcb43c56e696206074ec568d018b931fe5c6762dba64c24f7708dda2da/microsoft/TypeScript/issues/18075 |
| og:image:alt | TypeScript Version: 2.4.2 export type MyType = { id: number; } & { name: string; } & { photo: { id: number; } & { url: string; } } export let obj: MyType; export const photo: typeof obj.photo = { i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | asfernandes |
| 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