Title: Partial type passes for values that are strings and incorrect objects · Issue #16691 · microsoft/TypeScript · GitHub
Open Graph Title: Partial type passes for values that are strings and incorrect objects · Issue #16691 · microsoft/TypeScript
X Title: Partial type passes for values that are strings and incorrect objects · Issue #16691 · microsoft/TypeScript
Description: TypeScript Version: 2.3.4 Code interface Foo { key: string value: string } const shouldFail0: Partial
Open Graph Description: TypeScript Version: 2.3.4 Code interface Foo { key: string value: string } const shouldFail0: Partial
X Description: TypeScript Version: 2.3.4 Code interface Foo { key: string value: string } const shouldFail0: Partial<Foo> = '' // does not fail const shouldPass0: Partial<Foo> = {} // does not...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/16691
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Partial type passes for values that are strings and incorrect objects","articleBody":"**TypeScript Version:** 2.3.4\r\n\r\n**Code**\r\n\r\n```ts\r\ninterface Foo {\r\n key: string\r\n value: string\r\n}\r\n\r\nconst shouldFail0: Partial\u003cFoo> = '' // does not fail\r\nconst shouldPass0: Partial\u003cFoo> = {} // does not fail\r\nconst shouldFail1: Partial\u003cFoo> = {\r\n ker: ''\r\n} // fails\r\n\r\ninterface Bar {\r\n (): Partial\u003cFoo>\r\n}\r\n\r\nconst shouldFail2: Bar = () => ({\r\n car: ''\r\n}) // does not fails\r\nconst shouldFail3: Bar = () => ('') // does not fails\r\nconst shouldFail4: Bar = () => {\r\n return undefined\r\n} // fails\r\n```\r\n\r\nI've setup a [typescript playground example](typescript-playground-example).\r\n\r\n**Expected behavior:**\r\n\r\nPartial type should not pass for values that are strings or incorrect objects.\r\n\r\n**Actual behavior:**\r\n\r\nPartial type passes for values that are strings and incorrect objects.\r\n\r\n[typescript-playground-example]: https://www.typescriptlang.org/play/#src=interface%20Foo%20%7B%0D%0A%20%20%20%20key%3A%20string%0D%0A%20%20%20%20value%3A%20string%0D%0A%7D%0D%0A%0D%0A%0D%0Aconst%20shouldFail0%3A%20Partial%3CFoo%3E%20%3D%20''%20%2F%2F%20does%20not%20fail%0D%0A%0D%0Aconst%20shouldPass0%3A%20Partial%3CFoo%3E%20%3D%20%7B%7D%20%2F%2F%20does%20not%20fail%0D%0A%0D%0Aconst%20shouldFail1%3A%20Partial%3CFoo%3E%20%3D%20%7B%0D%0A%20%20%20%20ker%3A%20''%20%2F%2F%20fails%0D%0A%7D%0D%0A%0D%0Ainterface%20Bar%20%7B%0D%0A%20%20%20%20()%3A%20Partial%3CFoo%3E%0D%0A%7D%0D%0A%0D%0Aconst%20shouldFail2%3A%20Bar%20%3D%20()%20%3D%3E%20(%7B%0D%0A%20%20%20%20car%3A%20''%0D%0A%7D)%20%2F%2F%20does%20not%20fails%0D%0A%0D%0A%0D%0Aconst%20shouldFail3%3A%20Bar%20%3D%20()%20%3D%3E%20('')%20%2F%2F%20does%20not%20fails%0D%0A%0D%0Aconst%20shouldFail4%3A%20Bar%20%3D%20()%20%3D%3E%20%7B%0D%0A%20%20%20%20return%20undefined%0D%0A%7D%20%2F%2F%20fails%0D%0A","author":{"url":"https://github.com/luke-john","@type":"Person","name":"luke-john"},"datePublished":"2017-06-22T10:34:42Z","url":"https://github.com/microsoft/TypeScript/issues/16691"}
| 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:edf7e6b2-fe2c-0090-5a11-a2dffd115fe8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 84E2:172B92:7C678E:A84229:6B00DF0B |
| html-safe-nonce | afde6c129eb63a112506bcfa58243751b1d84ac14d4ca0e9cb347029ec360617 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NEUyOjE3MkI5Mjo3QzY3OEU6QTg0MjI5OjZCMDBERjBCIiwidmlzaXRvcl9pZCI6IjY3Mjg3OTQ2MTE1MzMyNzQ4OTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ed0000c3cafa2f022f6851cea8e023b1b5558e408f88c530b1e32ee6d717fdd2 |
| hovercard-subject-tag | issue:237802018 |
| 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/16691/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bc7224ead6800672909324f3013bf31714f3e2d2ab8e2535a18444c1d999d6b0/microsoft/TypeScript/issues/16691 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bc7224ead6800672909324f3013bf31714f3e2d2ab8e2535a18444c1d999d6b0/microsoft/TypeScript/issues/16691 |
| og:image:alt | TypeScript Version: 2.3.4 Code interface Foo { key: string value: string } const shouldFail0: Partial |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | luke-john |
| 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