Title: indexing with T extends keyof
Open Graph Title: indexing with T extends keyof
X Title: indexing with T extends keyof
Description: This breaks glimmer, and thereby our RWC (once sufficiently fixed in other ways) Code Isolated repro (needs dom lib for ElementTagNameMap and associated types): export function assertIsElement(node: Node | null): node is Element { let no...
Open Graph Description: This breaks glimmer, and thereby our RWC (once sufficiently fixed in other ways) Code Isolated repro (needs dom lib for ElementTagNameMap and associated types): export function assertIsElement(node...
X Description: This breaks glimmer, and thereby our RWC (once sufficiently fixed in other ways) Code Isolated repro (needs dom lib for ElementTagNameMap and associated types): export function assertIsElement(node...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/23977
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"indexing with T extends keyof \u003cLarge Union> causes OOM","articleBody":"This breaks `glimmer`, and thereby our RWC (once sufficiently fixed in other ways)\r\n\r\n**Code**\r\n\r\nIsolated repro (needs `dom` lib for `ElementTagNameMap` and associated types):\r\n```ts\r\nexport function assertIsElement(node: Node | null): node is Element {\r\n let nodeType = node === null ? null : node.nodeType;\r\n return nodeType === 1;\r\n}\r\n \r\nexport function assertNodeTagName\u003c\r\n T extends keyof ElementTagNameMap,\r\n U extends ElementTagNameMap[T]>(node: Node | null, tagName: T): node is U {\r\n if (assertIsElement(node)) {\r\n const nodeTagName = node.tagName.toLowerCase();\r\n return nodeTagName === tagName;\r\n }\r\n return false;\r\n}\r\n \r\nexport function assertNodeProperty\u003c\r\n T extends keyof ElementTagNameMap,\r\n P extends keyof ElementTagNameMap[T],\r\n V extends HTMLElementTagNameMap[T][P]>(node: Node | null, tagName: T, prop: P, value: V) {\r\n if (assertNodeTagName(node, tagName)) {\r\n node[prop];\r\n }\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\nNo crash.\r\n\r\n**Actual behavior:**\r\nOOM crash after a _very_ long delay.\r\n\r\nPreliminary investigation shows the OOM occurs when we try to get the distributed form of `keyof \u003cLarge Union>` - namely the process is defined recursively, so when the union has ~170 members, we create _170 intermediate types_ (flattening one member at a time, while also wasting time recalculating type flags and other bits we will never need) before getting the final, distributed result. Now, picture doing this on every relation comparison operation for `P` (this distribution is uncached), and _multiplying it_ for `V` in `assertNodeProperty` - the complexity is huge.\r\n\r\ncc @DanielRosenwasser since I think you care about when we break glimmer.\r\n","author":{"url":"https://github.com/weswigham","@type":"Person","name":"weswigham"},"datePublished":"2018-05-08T21:44:15Z","url":"https://github.com/microsoft/TypeScript/issues/23977"}
| 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:18e30ddc-b9e9-8608-5dea-35af2e5c8a42 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A864:B53AF:EF667C:13F4A20:6B010A7A |
| html-safe-nonce | efb4ee960c9220244d4e8b7d14be1fb97004c27a91e4ea9fe2226219ee60eb4d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBODY0OkI1M0FGOkVGNjY3QzoxM0Y0QTIwOjZCMDEwQTdBIiwidmlzaXRvcl9pZCI6IjQ0NzMzNDUxOTIzMzc5MzQ5NzAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 52e18b336dbabc3f0d3c6fcd366155a7e01ef2660f87abcb670854d438e1bd49 |
| hovercard-subject-tag | issue:321357683 |
| 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/23977/issue_layout |
| twitter:image | https://opengraph.githubassets.com/65d34fd621f95ab4248bd70927a22b7c497f5663ad3d0931e16a94f6b43910d3/microsoft/TypeScript/issues/23977 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/65d34fd621f95ab4248bd70927a22b7c497f5663ad3d0931e16a94f6b43910d3/microsoft/TypeScript/issues/23977 |
| og:image:alt | This breaks glimmer, and thereby our RWC (once sufficiently fixed in other ways) Code Isolated repro (needs dom lib for ElementTagNameMap and associated types): export function assertIsElement(node... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | weswigham |
| 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