Title: cannot enforce type shape when assigned to a conjunction · Issue #28642 · microsoft/TypeScript · GitHub
Open Graph Title: cannot enforce type shape when assigned to a conjunction · Issue #28642 · microsoft/TypeScript
X Title: cannot enforce type shape when assigned to a conjunction · Issue #28642 · microsoft/TypeScript
Description: TypeScript Version: 3.1.6, 3.2.0-rc, 3.3.0-dev.20181121 Search Terms: conjunction assignable wrong type Code declare const a: { a: string; b: number } declare const b: { a: string } & { b: number } declare function f(x: { [k: string]: st...
Open Graph Description: TypeScript Version: 3.1.6, 3.2.0-rc, 3.3.0-dev.20181121 Search Terms: conjunction assignable wrong type Code declare const a: { a: string; b: number } declare const b: { a: string } & { b: number }...
X Description: TypeScript Version: 3.1.6, 3.2.0-rc, 3.3.0-dev.20181121 Search Terms: conjunction assignable wrong type Code declare const a: { a: string; b: number } declare const b: { a: string } & { b: numb...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/28642
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"cannot enforce type shape when assigned to a conjunction","articleBody":"**TypeScript Version:** 3.1.6, 3.2.0-rc, 3.3.0-dev.20181121\r\n\r\n\r\n**Search Terms:**\r\nconjunction assignable wrong type\r\n\r\n**Code**\r\n\r\n```ts\r\ndeclare const a: { a: string; b: number }\r\ndeclare const b: { a: string } & { b: number }\r\ndeclare function f(x: { [k: string]: string }): void\r\nf(a) // error\r\nf(b) // NO error\r\n```\r\n\r\n**Expected behavior:**\r\nErrors on both f(a) and f(b)\r\n\r\n**Actual behavior:**\r\nErrors only on f(a)\r\n\r\n**Playground Link:** http://www.typescriptlang.org/play/#src=declare%20const%20a%3A%20%7B%20a%3A%20string%3B%20b%3A%20number%20%7D%0D%0Adeclare%20const%20b%3A%20%7B%20a%3A%20string%20%7D%20%26%20%7B%20b%3A%20number%20%7D%0D%0Adeclare%20function%20f(x%3A%20%7B%20%5Bk%3A%20string%5D%3A%20string%20%7D)%3A%20void%0D%0Af(a)%20%2F%2F%20error%0D%0Af(b)%20%2F%2F%20NO%20error\r\n\r\n**Related Issues:** https://github.com/gcanti/io-ts/issues/234#issuecomment-440752593\r\nhttps://github.com/gcanti/fp-ts-routing/issues/37\r\n\r\n","author":{"url":"https://github.com/sledorze","@type":"Person","name":"sledorze"},"datePublished":"2018-11-21T20:15:41Z","url":"https://github.com/microsoft/TypeScript/issues/28642"}
| 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:a30dde66-85c0-3713-6e44-43056724e5e3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DB4A:2270F4:28B0034:360BD42:6B01B212 |
| html-safe-nonce | d7a8dfdadffe8159ad80a6dff7aaae81d631556ce3125e5de63f7f59d567fc75 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjRBOjIyNzBGNDoyOEIwMDM0OjM2MEJENDI6NkIwMUIyMTIiLCJ2aXNpdG9yX2lkIjoiODQ3ODU5ODEyNzk3MTA1NDA5OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | abf08512d6bae5cdb9f1a7ea4392ce51f728d9c8397b4af32775026c1a028f68 |
| hovercard-subject-tag | issue:383277953 |
| 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/28642/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ee6dd214c6da3d2e82daf61e88a9cf999f397149f8c65f60bf1f17a95ecdea58/microsoft/TypeScript/issues/28642 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ee6dd214c6da3d2e82daf61e88a9cf999f397149f8c65f60bf1f17a95ecdea58/microsoft/TypeScript/issues/28642 |
| og:image:alt | TypeScript Version: 3.1.6, 3.2.0-rc, 3.3.0-dev.20181121 Search Terms: conjunction assignable wrong type Code declare const a: { a: string; b: number } declare const b: { a: string } & { b: number }... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sledorze |
| 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