|
| 1 | +=== tests/cases/compiler/intersectionsOfLargeUnions.ts === |
| 2 | +// Repro from #23977 |
| 3 | + |
| 4 | +export function assertIsElement(node: Node | null): node is Element { |
| 5 | +>assertIsElement : Symbol(assertIsElement, Decl(intersectionsOfLargeUnions.ts, 0, 0)) |
| 6 | +>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 2, 32)) |
| 7 | +>Node : Symbol(Node, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) |
| 8 | +>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 2, 32)) |
| 9 | +>Element : Symbol(Element, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) |
| 10 | + |
| 11 | + let nodeType = node === null ? null : node.nodeType; |
| 12 | +>nodeType : Symbol(nodeType, Decl(intersectionsOfLargeUnions.ts, 3, 7)) |
| 13 | +>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 2, 32)) |
| 14 | +>node.nodeType : Symbol(Node.nodeType, Decl(lib.d.ts, --, --)) |
| 15 | +>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 2, 32)) |
| 16 | +>nodeType : Symbol(Node.nodeType, Decl(lib.d.ts, --, --)) |
| 17 | + |
| 18 | + return nodeType === 1; |
| 19 | +>nodeType : Symbol(nodeType, Decl(intersectionsOfLargeUnions.ts, 3, 7)) |
| 20 | +} |
| 21 | + |
| 22 | +export function assertNodeTagName< |
| 23 | +>assertNodeTagName : Symbol(assertNodeTagName, Decl(intersectionsOfLargeUnions.ts, 5, 1)) |
| 24 | + |
| 25 | + T extends keyof ElementTagNameMap, |
| 26 | +>T : Symbol(T, Decl(intersectionsOfLargeUnions.ts, 7, 34)) |
| 27 | +>ElementTagNameMap : Symbol(ElementTagNameMap, Decl(lib.d.ts, --, --)) |
| 28 | + |
| 29 | + U extends ElementTagNameMap[T]>(node: Node | null, tagName: T): node is U { |
| 30 | +>U : Symbol(U, Decl(intersectionsOfLargeUnions.ts, 8, 38)) |
| 31 | +>ElementTagNameMap : Symbol(ElementTagNameMap, Decl(lib.d.ts, --, --)) |
| 32 | +>T : Symbol(T, Decl(intersectionsOfLargeUnions.ts, 7, 34)) |
| 33 | +>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 9, 36)) |
| 34 | +>Node : Symbol(Node, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) |
| 35 | +>tagName : Symbol(tagName, Decl(intersectionsOfLargeUnions.ts, 9, 54)) |
| 36 | +>T : Symbol(T, Decl(intersectionsOfLargeUnions.ts, 7, 34)) |
| 37 | +>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 9, 36)) |
| 38 | +>U : Symbol(U, Decl(intersectionsOfLargeUnions.ts, 8, 38)) |
| 39 | + |
| 40 | + if (assertIsElement(node)) { |
| 41 | +>assertIsElement : Symbol(assertIsElement, Decl(intersectionsOfLargeUnions.ts, 0, 0)) |
| 42 | +>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 9, 36)) |
| 43 | + |
| 44 | + const nodeTagName = node.tagName.toLowerCase(); |
| 45 | +>nodeTagName : Symbol(nodeTagName, Decl(intersectionsOfLargeUnions.ts, 11, 13)) |
| 46 | +>node.tagName.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) |
| 47 | +>node.tagName : Symbol(Element.tagName, Decl(lib.d.ts, --, --)) |
| 48 | +>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 9, 36)) |
| 49 | +>tagName : Symbol(Element.tagName, Decl(lib.d.ts, --, --)) |
| 50 | +>toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) |
| 51 | + |
| 52 | + return nodeTagName === tagName; |
| 53 | +>nodeTagName : Symbol(nodeTagName, Decl(intersectionsOfLargeUnions.ts, 11, 13)) |
| 54 | +>tagName : Symbol(tagName, Decl(intersectionsOfLargeUnions.ts, 9, 54)) |
| 55 | + } |
| 56 | + return false; |
| 57 | +} |
| 58 | + |
| 59 | +export function assertNodeProperty< |
| 60 | +>assertNodeProperty : Symbol(assertNodeProperty, Decl(intersectionsOfLargeUnions.ts, 15, 1)) |
| 61 | + |
| 62 | + T extends keyof ElementTagNameMap, |
| 63 | +>T : Symbol(T, Decl(intersectionsOfLargeUnions.ts, 17, 35)) |
| 64 | +>ElementTagNameMap : Symbol(ElementTagNameMap, Decl(lib.d.ts, --, --)) |
| 65 | + |
| 66 | + P extends keyof ElementTagNameMap[T], |
| 67 | +>P : Symbol(P, Decl(intersectionsOfLargeUnions.ts, 18, 38)) |
| 68 | +>ElementTagNameMap : Symbol(ElementTagNameMap, Decl(lib.d.ts, --, --)) |
| 69 | +>T : Symbol(T, Decl(intersectionsOfLargeUnions.ts, 17, 35)) |
| 70 | + |
| 71 | + V extends HTMLElementTagNameMap[T][P]>(node: Node | null, tagName: T, prop: P, value: V) { |
| 72 | +>V : Symbol(V, Decl(intersectionsOfLargeUnions.ts, 19, 41)) |
| 73 | +>HTMLElementTagNameMap : Symbol(HTMLElementTagNameMap, Decl(lib.d.ts, --, --)) |
| 74 | +>T : Symbol(T, Decl(intersectionsOfLargeUnions.ts, 17, 35)) |
| 75 | +>P : Symbol(P, Decl(intersectionsOfLargeUnions.ts, 18, 38)) |
| 76 | +>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 20, 43)) |
| 77 | +>Node : Symbol(Node, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) |
| 78 | +>tagName : Symbol(tagName, Decl(intersectionsOfLargeUnions.ts, 20, 61)) |
| 79 | +>T : Symbol(T, Decl(intersectionsOfLargeUnions.ts, 17, 35)) |
| 80 | +>prop : Symbol(prop, Decl(intersectionsOfLargeUnions.ts, 20, 73)) |
| 81 | +>P : Symbol(P, Decl(intersectionsOfLargeUnions.ts, 18, 38)) |
| 82 | +>value : Symbol(value, Decl(intersectionsOfLargeUnions.ts, 20, 82)) |
| 83 | +>V : Symbol(V, Decl(intersectionsOfLargeUnions.ts, 19, 41)) |
| 84 | + |
| 85 | + if (assertNodeTagName(node, tagName)) { |
| 86 | +>assertNodeTagName : Symbol(assertNodeTagName, Decl(intersectionsOfLargeUnions.ts, 5, 1)) |
| 87 | +>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 20, 43)) |
| 88 | +>tagName : Symbol(tagName, Decl(intersectionsOfLargeUnions.ts, 20, 61)) |
| 89 | + |
| 90 | + node[prop]; |
| 91 | +>node : Symbol(node, Decl(intersectionsOfLargeUnions.ts, 20, 43)) |
| 92 | +>prop : Symbol(prop, Decl(intersectionsOfLargeUnions.ts, 20, 73)) |
| 93 | + } |
| 94 | +} |
| 95 | + |
0 commit comments