Title: Weird behaviour with union types and 'strict' object literals · Issue #5237 · microsoft/TypeScript · GitHub
Open Graph Title: Weird behaviour with union types and 'strict' object literals · Issue #5237 · microsoft/TypeScript
X Title: Weird behaviour with union types and 'strict' object literals · Issue #5237 · microsoft/TypeScript
Description: I'm not sure if this a bug or by design, but it's confusing me: interface Constraint { message?: string; } var badConstraint: Constraint = { messge: "rte" // errors as expected }; var goodConstraint: Constraint | boolean = { messge: "rte...
Open Graph Description: I'm not sure if this a bug or by design, but it's confusing me: interface Constraint { message?: string; } var badConstraint: Constraint = { messge: "rte" // errors as expected }; var goodConstrain...
X Description: I'm not sure if this a bug or by design, but it's confusing me: interface Constraint { message?: string; } var badConstraint: Constraint = { messge: "rte" // errors as expected };...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/5237
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Weird behaviour with union types and 'strict' object literals","articleBody":"I'm not sure if this a bug or by design, but it's confusing me:\n\n``` typescript\ninterface Constraint {\n message?: string;\n}\n\nvar badConstraint: Constraint = {\n messge: \"rte\" // errors as expected\n};\n\nvar goodConstraint: Constraint | boolean = {\n messge: \"rte\" // I expect this to error!\n};\n```\n\nCan anybody explain what is going on here?\n\nhttp://www.typescriptlang.org/Playground/#src=interface%20Constraint%20%7B%0D%0A%20%20message%3F%3A%20string%3B%0D%0A%7D%0D%0A%0D%0Avar%20badConstraint%3A%20Constraint%20%3D%20%7B%0D%0A%20%20messge%3A%20%22rte%22%20%2F%2F%20errors%20as%20expected%0D%0A%7D%3B%0D%0A%0D%0Avar%20goodConstraint%3A%20Constraint%20%7C%20boolean%20%3D%20%7B%0D%0A%20%20messge%3A%20%22rte%22%20%2F%2F%20I%20expect%20this%20to%20error!%0D%0A%7D%3B%0D%0A\n","author":{"url":"https://github.com/jonnystoten","@type":"Person","name":"jonnystoten"},"datePublished":"2015-10-13T11:49:01Z","url":"https://github.com/microsoft/TypeScript/issues/5237"}
| 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:89108d4a-5c61-a6e8-701f-33e690104701 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E790:BB5B5:5BD689:7A1661:6B00A91B |
| html-safe-nonce | 9cba502be31aeb90f4eb616302c16472f7875373562aa56e65ae66779f9fb046 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNzkwOkJCNUI1OjVCRDY4OTo3QTE2NjE6NkIwMEE5MUIiLCJ2aXNpdG9yX2lkIjoiNDEyMjk2ODEwMzk5NjkyNjIzNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0757d2f57a42198a49d9c36dd80ba385f59f1a04f9df35412a99bbd4df1259bc |
| hovercard-subject-tag | issue:111163623 |
| 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/5237/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1b8633298a04b24276b598943231d38870d7d73d005f0119960d3d217fe37c8d/microsoft/TypeScript/issues/5237 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1b8633298a04b24276b598943231d38870d7d73d005f0119960d3d217fe37c8d/microsoft/TypeScript/issues/5237 |
| og:image:alt | I'm not sure if this a bug or by design, but it's confusing me: interface Constraint { message?: string; } var badConstraint: Constraint = { messge: "rte" // errors as expected }; var goodConstrain... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jonnystoten |
| hostname | github.com |
| expected-hostname | github.com |
| None | 455b493e3402a3a3a06beac5d20bb7db3da060808b220aa48d6a7eca7c59863a |
| 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 | 2f575159976167242d488c0b062eb355c4e198b7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width