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