Title: Design Meeting Notes, 3/31/2021 · Issue #43582 · microsoft/TypeScript · GitHub
Open Graph Title: Design Meeting Notes, 3/31/2021 · Issue #43582 · microsoft/TypeScript
X Title: Design Meeting Notes, 3/31/2021 · Issue #43582 · microsoft/TypeScript
Description: Tracking Substitution Type Replacement #43427 #43425 #43439 We create "substitution types" in conditional types - when writing T extends U ? TrueBranch : FalseBranch, we substitute T with something that's sort of equivalent to T & U in t...
Open Graph Description: Tracking Substitution Type Replacement #43427 #43425 #43439 We create "substitution types" in conditional types - when writing T extends U ? TrueBranch : FalseBranch, we substitute T with something...
X Description: Tracking Substitution Type Replacement #43427 #43425 #43439 We create "substitution types" in conditional types - when writing T extends U ? TrueBranch : FalseBranch, we substitute T with...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/43582
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Design Meeting Notes, 3/31/2021","articleBody":"# Tracking Substitution Type Replacement\r\n\r\nhttps://github.com/microsoft/TypeScript/issues/43427\r\nhttps://github.com/microsoft/TypeScript/issues/43425\r\nhttps://github.com/microsoft/TypeScript/pull/43439\r\n\r\n* We create \"substitution types\" in conditional types - when writing `T extends U ? TrueBranch : FalseBranch`, we substitute `T` with something that's sort of equivalent to `T & U` in the `TrueBranch`.\r\n* Doing a \"dumb\" substitution.\r\n* When did we start supporting substitution types on primitives/literals?\r\n * Turns out it's relied upon quite a bit!\r\n * If you write `\"foo\" extends keyof T ? ... : ...`, you want to make a substitution type of `\"foo\"` and `keyof T` so that you can index into `T` with it in the true branch!\r\n * Example:\r\n \r\n ```ts\r\n // Ensure the following real-world example that relies on substitution still works\r\n type ExtractParameters\u003cT> = \"parameters\" extends keyof T\r\n // The above allows \"parameters\" to index `T` since all later\r\n // instances are actually implicitly `\"parameters\" & keyof T`\r\n ? {\r\n [K in keyof T[\"parameters\"]]: T[\"parameters\"][K];\r\n }[keyof T[\"parameters\"]]\r\n : {};\r\n ```\r\n* You can figure that in *contravariant* positions, you don't actually want to produce the substitution type.\r\n * The issue is that not every use of a type implies strict variance. You could end up with some invariant and covariant and contravariant uses.\r\n* Should you create *unions* in contravariant positions?\r\n * Hard to reason about - leave it alone for now.\r\n* PR seems right, get some more eyes on it.\r\n\r\n# Fixing Excessive Stack Depth Issues\r\n\r\nhttps://github.com/microsoft/TypeScript/issues/43249\r\n\r\n* Lot of people hitting this issue.\r\n* Tracks back to https://github.com/microsoft/TypeScript/pull/30639\r\n* Came up with a targeted fix that special-cases arrays, but doesn't fix everything.\r\n* Unclear if there's a potential better way to write `FlatArray`. Will experiment.\r\n\r\n# Performance Depends on Declaration Order\r\n\r\nhttps://github.com/microsoft/TypeScript/issues/43437\r\n\r\n* If you have a `const` that uses an interface before it's declared...it's somehow slower!\r\n* The spread is also suspicious - spreads can create huge anonymous types.\r\n* Potentially related to lower type IDs.\r\n * Subtype reduction picks the one with a lower type ID, but that could be worse to compare against.\r\n * Also, might just not be hitting the relationship cache.\r\n* Investigation: start at high number, go down.\r\n * It didn't work. 😱\r\n* Unclear what to do about it though.\r\n\r\n# Decorators Metadata Compat for SES\r\n\r\nhttps://github.com/microsoft/TypeScript/issues/43463","author":{"url":"https://github.com/DanielRosenwasser","@type":"Person","name":"DanielRosenwasser"},"datePublished":"2021-04-07T22:04:33Z","url":"https://github.com/microsoft/TypeScript/issues/43582"}
| 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:6b3597a0-6957-c340-283a-4df8c075b20b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 955C:1D86C4:1DD23AA:25D6B90:6B01602E |
| html-safe-nonce | 9538bc15bebfa7147097e6b0fb8ab988cbfddfc96dd0a0c2e6e78a0db6dc5dae |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTVDOjFEODZDNDoxREQyM0FBOjI1RDZCOTA6NkIwMTYwMkUiLCJ2aXNpdG9yX2lkIjoiNjg2NzA5ODQ5NDEwOTMxMTAyMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 29328b358050e2d42961f69f695e68efd5b2f9096dfa4c08f35e8aefb256dd42 |
| hovercard-subject-tag | issue:852859462 |
| 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/43582/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3f66ba0df4abd802432b381683fe97e23aeb68a46397bf001bc0fa20f189de8f/microsoft/TypeScript/issues/43582 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3f66ba0df4abd802432b381683fe97e23aeb68a46397bf001bc0fa20f189de8f/microsoft/TypeScript/issues/43582 |
| og:image:alt | Tracking Substitution Type Replacement #43427 #43425 #43439 We create "substitution types" in conditional types - when writing T extends U ? TrueBranch : FalseBranch, we substitute T with something... |
| 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 | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width