Title: Design Meeting Notes, 12/20/2019 · Issue #35807 · microsoft/TypeScript · GitHub
Open Graph Title: Design Meeting Notes, 12/20/2019 · Issue #35807 · microsoft/TypeScript
X Title: Design Meeting Notes, 12/20/2019 · Issue #35807 · microsoft/TypeScript
Description: A Stricter Subtype Relationship Issue: #35414 PR: #35659 We have this thing where we perform union subtype reduction - reducing constituents of unions when a union contains a supertype. But we sort unions by a type IDs, but that's not a ...
Open Graph Description: A Stricter Subtype Relationship Issue: #35414 PR: #35659 We have this thing where we perform union subtype reduction - reducing constituents of unions when a union contains a supertype. But we sort...
X Description: A Stricter Subtype Relationship Issue: #35414 PR: #35659 We have this thing where we perform union subtype reduction - reducing constituents of unions when a union contains a supertype. But we sort...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/35807
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Design Meeting Notes, 12/20/2019","articleBody":"# A Stricter Subtype Relationship\r\n\r\n\r\n* Issue: https://github.com/microsoft/TypeScript/issues/35414\r\n* PR: https://github.com/microsoft/TypeScript/pull/35659\r\n\r\n* We have this thing where we perform union subtype reduction - reducing constituents of unions when a union contains a supertype.\r\n* But we sort unions by a type IDs, but that's not a \"stable\" ordering.\r\n * Our current subtype relationship contains \"ties\" though - several types can be subtypes of each other.\r\n * First type ID wins, so if you reorder declarations/instantiations in your program, the behavior changes! That's undesirable.\r\n* The solution is to avoid places where types can \"tie\" in which types are supertypes.\r\n* It's strictly a good thing in subtype reduction, but it can have effects elsewhere.\r\n * One effect that's measured is that two constituents might be preserved in a reduced union (something we're willing to take).\r\n * Additionally, because of our union merging, we might have different effects on which signatures are present.\r\n * Also seeing differences in overload resolution because overload resolution does a subtype pass.\r\n * Historical reasons for saying `any` is not the best type to choose from.\r\n* These changes introduce a lot of potential breaks elsewhere, so we introduced a separate relationship to the compiler.\r\n * Ideally we'd use this new subtype relationship everywhere, but we don't want to impact too much.\r\n* Example breaks seem \"good\" but hard to deal with.\r\n* Could we imagine a strict mode that uses the strict subtype relationship?\r\n * Maybe! It's worth thinking about.\r\n* As a compiler writer, what relationship do I use?\r\n * \\[\\[rules that went by too fast, but you can consult with the team]]\r\n* Conclusion\r\n * Turn it on just for subtype reduction.\r\n * Try it out everywhere, see what breaks, see if it can fit under a strict mode - i.e. `--strictSubtypes` but with a better name.\r\n\r\n# Assume Changes Only Affect Dependencies\r\n\r\n* Issue: https://github.com/microsoft/TypeScript/issues/33329\r\n* PR: https://github.com/microsoft/TypeScript/pull/35711\r\n\r\n* VS Code has a tool called `gulp-tsb`\r\n * Its `--watch` is faster than `tsc --watch` because it assumes only direct dependencies will be affected.\r\n * Common case is that they won't, so it's a nice optimization to iterate quickly, but it's definitely very sloppy/inaccurate.\r\n * Takes incremental check time down from 14 seconds to 1 second.\r\n* \\[\\[Bikeshed on name]]\r\n\r\n# Type-Only Imports/Exports\r\n\r\nhttps://github.com/microsoft/TypeScript/pull/35200\r\n\r\n* Scenarios\r\n * Re-export a type in `isolatedModules`\r\n * Stop eliding imports when I do DI\r\n * \r\n* Behavior\r\n * Changed default emit behavior to preserve imports\r\n * Flag to opt in to the old behavior\r\n* Effect\r\n * Can increase bundle sizes 👎\r\n * Hard to determine where to fix 👎\r\n * Runtime behavior might break, or you might not notice the change at all 👎\r\n* Proposals to mitigate issues\r\n * Proposal 1\r\n * Add error on regular imports used only as types.\r\n * Disable error via a flag.\r\n * Proposal 2\r\n * Keep today's emit behavior.\r\n * Opt into preserved imports via a flag\r\n * Optionally enable this in `tsc --init`\r\n * Optionally add a flag to force type-only imports for identifiers used only as types\r\n * Proposal 3\r\n * Transition plan\r\n* 3 years from now where do we want to be?\r\n * Can we remove things from the import list under `isolatedModules` currently?\r\n * Yes\r\n * Anecdotal from Wesley: when I transitioned our unit tests into modules, there were a lot of issues because our unittests were only being included via type-imports.\r\n * Experience is that elision has undesirable behavior\r\n * This is a very big breaking change even if you phase it over several releases.\r\n * People are in an unknown state of what they want - only make noise (i.e. give an error) when the intent isn't clear.\r\n* Can this be a strict mode flag?\r\n * Strict flags have never affected emit.\r\n* Could this be mitigated with a tristate flag?\r\n * Well then what's the default?\r\n* Conclusion:\r\n * The safer proposal 2\r\n * Leaves our options open\r\n * Implement option as a tristate\r\n * `preserve` be default in `tsc --init`\r\n * Send PRs to 3rd party tools\r\n * Turn it on in scaffolding tools\r\n * Babel\r\n * Need to signal to the team, maybe need a flag (@hzoo).\r\n\r\n# Use Getters for Live Bindings\r\n\r\nhttps://github.com/microsoft/TypeScript/pull/33587\r\n\r\n* Turns out even we were giving people \"wrong\" exports because of this.\r\n* Let's do it.","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2019-12-20T21:26:17Z","url":"https://github.com/microsoft/TypeScript/issues/35807"}
| 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:a8154052-299e-f1f1-0705-a0b087c56260 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C05A:1D86C4:CBA622:103B55C:6B010007 |
| html-safe-nonce | 75416484fb739d6f98efed5640e9b99eda7645e08d8d433302056ee9a6b7734c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMDVBOjFEODZDNDpDQkE2MjI6MTAzQjU1Qzo2QjAxMDAwNyIsInZpc2l0b3JfaWQiOiI3MjExMTIzMDkzODkxMjUyMjMyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | eb47629fcba4dc905d488839eb3f1cbae06c108878bc8954640572ec98463211 |
| hovercard-subject-tag | issue:541207224 |
| 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/35807/issue_layout |
| twitter:image | https://opengraph.githubassets.com/711e9358a5f3ca6ffae2f9c3d5c70c7163fec5dcf654bd7e0d8999ad7a153de9/microsoft/TypeScript/issues/35807 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/711e9358a5f3ca6ffae2f9c3d5c70c7163fec5dcf654bd7e0d8999ad7a153de9/microsoft/TypeScript/issues/35807 |
| og:image:alt | A Stricter Subtype Relationship Issue: #35414 PR: #35659 We have this thing where we perform union subtype reduction - reducing constituents of unions when a union contains a supertype. But we sort... |
| 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