Title: Design Meeting Notes, 11/3/2017 · Issue #19722 · microsoft/TypeScript · GitHub
Open Graph Title: Design Meeting Notes, 11/3/2017 · Issue #19722 · microsoft/TypeScript
X Title: Design Meeting Notes, 11/3/2017 · Issue #19722 · microsoft/TypeScript
Description: Stricter Tuple Types #17765 Tried freshness, generally encountered strange behavior. Adding an explicit length property breaks fairly little Things we catch: Accidental Haskell-style list syntax: [T] instead of T[]. This is actually a si...
Open Graph Description: Stricter Tuple Types #17765 Tried freshness, generally encountered strange behavior. Adding an explicit length property breaks fairly little Things we catch: Accidental Haskell-style list syntax: [...
X Description: Stricter Tuple Types #17765 Tried freshness, generally encountered strange behavior. Adding an explicit length property breaks fairly little Things we catch: Accidental Haskell-style list syntax: [...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/19722
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Design Meeting Notes, 11/3/2017","articleBody":"# Stricter Tuple Types\r\n\r\n#17765\r\n\r\n* Tried freshness, generally encountered strange behavior.\r\n* Adding an explicit `length` property breaks fairly little\r\n * Things we catch:\r\n * Accidental Haskell-style list syntax: `[T]` instead of `T[]`.\r\n * This is actually a singleton tuple of `T` instead of `Array\u003cT>`\r\n * Caught ~10 instances of that.\r\n * Actual errors where people misunderstood the API\r\n * Found this in Highcharts & Leaflet\r\n * Downside is you can't cast between these anymore without an intermediate.\r\n * One break in firebase-js-sdk\r\n* Then we tried changing tuples to extend `ReadonlyArray` instead.\r\n * Which makes tuple elements immutable which is more debatable.\r\n * And problematically means you can't assign to array\r\n * Didn't find many errors outside of the test suite.\r\n * Added another break in firebase-js-sdk\r\n* What about `push: never; pop: never;`?\r\n * Means you can still assign to arrays, but can't mutate them directly.\r\n * Kind of cheating, but a reasonable compromise in intent.\r\n * Well maybe, but #11412\r\n * Should look into this!\r\n* Conclusion: try out the stubs, keep testing on real world code.\r\n\r\n# `instanceof` checks\r\n\r\n#19671\r\n\r\n* Idea: `instanceof` has worked structurally since forever with us.\r\n * But because of structural compatibility, things that were structurally identical would act *very* strangely.\r\n * We want to change this to actually check the base types as it does at runtime.\r\n* Things the PR does\r\n * Makes `instanceof` nominal\r\n * Changes to subtype reduction to accomodate this new behavior.\r\n * Take the following:\r\n ```ts\r\n class A {}\r\n class B extends A {}\r\n\r\n class Q extends A { qProp: any; }\r\n\r\n let blah = Math.random() ? new B() : new Q();\r\n ```\r\n * Under old subtype reduction behavior, `blah` has type `B`; means the negative check for `blah instanceof B` gives you `never`:\r\n\r\n ```ts\r\n if (blah instanceof B) {\r\n blah; /* has type `B` */\r\n }\r\n else {\r\n blah; /* has type `never` */\r\n }\r\n ```\r\n * Under new behavior, we aren't as agressive; `blah` has type `B | D`\r\n\r\n ```ts\r\n if (blah instanceof B) {\r\n blah; /* has type `B` */\r\n }\r\n else {\r\n blah; /* has type `D` */\r\n }\r\n ```\r\n * This is better, but it affects things like callability.\r\n* Do we care about how ES2015 allows this behavior to be overridden with `Symbol.instanceOf`?\r\n * Most people just don't do this.\r\n* It's in nightly now.","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2017-11-03T20:25:13Z","url":"https://github.com/microsoft/TypeScript/issues/19722"}
| 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:150cbe9c-6cf0-80dc-b923-db33dee7fea6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ED24:19E4BB:CCCCA7:1068277:6B010200 |
| html-safe-nonce | 1db62dbf3ed91840ac2afc629cad66df76cfdeb2eab83275ff8531946ff0f000 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDI0OjE5RTRCQjpDQ0NDQTc6MTA2ODI3Nzo2QjAxMDIwMCIsInZpc2l0b3JfaWQiOiIxMDE4MTQzOTgwOTU0NjQ5MDg4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | dce4e088364c0a17ee4c1de794516c6e5a32e8aae76b56fe3643d3a6aa826dc7 |
| hovercard-subject-tag | issue:271108607 |
| 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/19722/issue_layout |
| twitter:image | https://opengraph.githubassets.com/68213b3612410750ab953b361ea53ad62212d2bf1a60ee00ce7bac5e71944d33/microsoft/TypeScript/issues/19722 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/68213b3612410750ab953b361ea53ad62212d2bf1a60ee00ce7bac5e71944d33/microsoft/TypeScript/issues/19722 |
| og:image:alt | Stricter Tuple Types #17765 Tried freshness, generally encountered strange behavior. Adding an explicit length property breaks fairly little Things we catch: Accidental Haskell-style list syntax: [... |
| 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 | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| 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 | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width