Title: Should unions and non-primitives be allowed for relational comparisons? · Issue #5156 · microsoft/TypeScript · GitHub
Open Graph Title: Should unions and non-primitives be allowed for relational comparisons? · Issue #5156 · microsoft/TypeScript
X Title: Should unions and non-primitives be allowed for relational comparisons? · Issue #5156 · microsoft/TypeScript
Description: To quote 4.19.1 of the spec: 4.19.3 The <, >, <=, >=, ==, !=, ===, and !== operators These operators require one or both of the operand types to be assignable to the other. The result is always of the Boolean primitive type. Any Boolean ...
Open Graph Description: To quote 4.19.1 of the spec: 4.19.3 The <, >, <=, >=, ==, !=, ===, and !== operators These operators require one or both of the operand types to be assignable to the other. The result is always of ...
X Description: To quote 4.19.1 of the spec: 4.19.3 The <, >, <=, >=, ==, !=, ===, and !== operators These operators require one or both of the operand types to be assignable to the other. The result i...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/5156
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Should unions and non-primitives be allowed for relational comparisons?","articleBody":"[To quote 4.19.1 of the spec](https://github.com/Microsoft/TypeScript/blob/738b26f065a4d859c19b4c417b359baf1d74900a/doc/spec.md#4193-the--------and--operators):\n\n\u003e ### \u003csection name=\"4.19.3\" is=\"a\" /\u003e4.19.3 The \u0026lt;, \u003e, \u0026lt;=, \u003e=, ==, !=, ===, and !== operators\n\u003e \n\u003e These operators require one or both of the operand types to be assignable to the other. The result is always of the Boolean primitive type.\n\u003e \n\u003e | | Any | Boolean | Number | String | Other |\n\u003e | :-: | :-: | :-: | :-: | :-: | :-: |\n\u003e | Any | Boolean | Boolean | Boolean | Boolean | Boolean |\n\u003e | Boolean | Boolean | Boolean | | | |\n\u003e | Number | Boolean | | Boolean | | |\n\u003e | String | Boolean | | | Boolean | |\n\u003e | Other | Boolean | | | | Boolean |\n\nThis has probably unintended consequences in the case of union types:\n\n``` TypeScript\nvar x: string | number = \"hello\";\nvar y: number = 10;\nvar z: string | number = -1;\n\nif (x \u003c y \u0026\u0026 x \u003c= z) {\n}\n```\n\nThe question is: is this still desirable behavior?\n\n@ahejlsberg @RyanCavanaugh @danquirk @mhegazy @JsonFreeman\n","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2015-10-07T19:38:02.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/5156/TypeScript/issues/5156"}
| 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:634f7889-6105-2e70-53e0-aab078ca71bd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CD32:292B12:B30AD9:EB9E84:6A62B53B |
| html-safe-nonce | 6af096d5a8e0b5f4aeda390f4a7144cdb84cd0fc69936b43bca839fb456f5bfa |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDMyOjI5MkIxMjpCMzBBRDk6RUI5RTg0OjZBNjJCNTNCIiwidmlzaXRvcl9pZCI6IjIzODYxNTcxODg5MjA1NzkxNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0d37fa1279fe48053f70de87e06e537bd52d7c48a1c5a324b378f7ba8c0f225a |
| hovercard-subject-tag | issue:110300862 |
| 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/5156/issue_layout |
| twitter:image | https://opengraph.githubassets.com/989e21bce1753cd19bc56b57776b07231aed8ce8f059234ff008b90fe9467415/microsoft/TypeScript/issues/5156 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/989e21bce1753cd19bc56b57776b07231aed8ce8f059234ff008b90fe9467415/microsoft/TypeScript/issues/5156 |
| og:image:alt | To quote 4.19.1 of the spec: 4.19.3 The <, >, <=, >=, ==, !=, ===, and !== operators These operators require one or both of the operand types to be assignable to the other. The result is always of ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DanielRosenwasser |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2738d7125e864b55224a8bc40c72c220ca7d2c73f91a7bb8d69dffe9d35e997d |
| 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 | bf54af498459157b66a67136f992a68752cdbb54 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width