mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Add regression test
This commit is contained in:
parent
426a63e8b6
commit
1c3dbd4f4b
27
tests/cases/compiler/intersectionsOfLargeUnions.ts
Normal file
27
tests/cases/compiler/intersectionsOfLargeUnions.ts
Normal file
@ -0,0 +1,27 @@
|
||||
// @strict: true
|
||||
|
||||
// Repro from #23977
|
||||
|
||||
export function assertIsElement(node: Node | null): node is Element {
|
||||
let nodeType = node === null ? null : node.nodeType;
|
||||
return nodeType === 1;
|
||||
}
|
||||
|
||||
export function assertNodeTagName<
|
||||
T extends keyof ElementTagNameMap,
|
||||
U extends ElementTagNameMap[T]>(node: Node | null, tagName: T): node is U {
|
||||
if (assertIsElement(node)) {
|
||||
const nodeTagName = node.tagName.toLowerCase();
|
||||
return nodeTagName === tagName;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function assertNodeProperty<
|
||||
T extends keyof ElementTagNameMap,
|
||||
P extends keyof ElementTagNameMap[T],
|
||||
V extends HTMLElementTagNameMap[T][P]>(node: Node | null, tagName: T, prop: P, value: V) {
|
||||
if (assertNodeTagName(node, tagName)) {
|
||||
node[prop];
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user