Skip to content

Commit 29e6d66

Browse files
Fix lib.includes('dom') check in containerSeemsToBeEmptyDomElement (#61481)
1 parent 19b7772 commit 29e6d66

6 files changed

+56
-1
lines changed

Diff for: src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34454,7 +34454,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3445434454
}
3445534455

3445634456
function containerSeemsToBeEmptyDomElement(containingType: Type) {
34457-
return (compilerOptions.lib && !compilerOptions.lib.includes("dom")) &&
34457+
return (compilerOptions.lib && !compilerOptions.lib.includes("lib.dom.d.ts")) &&
3445834458
everyContainedType(containingType, type => type.symbol && /^(?:EventTarget|Node|(?:HTML[a-zA-Z]*)?Element)$/.test(unescapeLeadingUnderscores(type.symbol.escapedName))) &&
3445934459
isEmptyObjectType(containingType);
3446034460
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
missingDomElement_UsingDomLib.ts(3,37): error TS2339: Property 'textContent' does not exist on type 'HTMLMissingElement'.
2+
3+
4+
==== missingDomElement_UsingDomLib.ts (1 errors) ====
5+
interface HTMLMissingElement {}
6+
7+
(({}) as any as HTMLMissingElement).textContent;
8+
~~~~~~~~~~~
9+
!!! error TS2339: Property 'textContent' does not exist on type 'HTMLMissingElement'.
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//// [tests/cases/compiler/missingDomElement_UsingDomLib.ts] ////
2+
3+
//// [missingDomElement_UsingDomLib.ts]
4+
interface HTMLMissingElement {}
5+
6+
(({}) as any as HTMLMissingElement).textContent;
7+
8+
9+
//// [missingDomElement_UsingDomLib.js]
10+
({}).textContent;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//// [tests/cases/compiler/missingDomElement_UsingDomLib.ts] ////
2+
3+
=== missingDomElement_UsingDomLib.ts ===
4+
interface HTMLMissingElement {}
5+
>HTMLMissingElement : Symbol(HTMLMissingElement, Decl(missingDomElement_UsingDomLib.ts, 0, 0))
6+
7+
(({}) as any as HTMLMissingElement).textContent;
8+
>HTMLMissingElement : Symbol(HTMLMissingElement, Decl(missingDomElement_UsingDomLib.ts, 0, 0))
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//// [tests/cases/compiler/missingDomElement_UsingDomLib.ts] ////
2+
3+
=== missingDomElement_UsingDomLib.ts ===
4+
interface HTMLMissingElement {}
5+
6+
(({}) as any as HTMLMissingElement).textContent;
7+
>(({}) as any as HTMLMissingElement).textContent : any
8+
> : ^^^
9+
>(({}) as any as HTMLMissingElement) : HTMLMissingElement
10+
> : ^^^^^^^^^^^^^^^^^^
11+
>({}) as any as HTMLMissingElement : HTMLMissingElement
12+
> : ^^^^^^^^^^^^^^^^^^
13+
>({}) as any : any
14+
> : ^^^
15+
>({}) : {}
16+
> : ^^
17+
>{} : {}
18+
> : ^^
19+
>textContent : any
20+
> : ^^^
21+
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @lib: es5,dom
2+
3+
interface HTMLMissingElement {}
4+
5+
(({}) as any as HTMLMissingElement).textContent;

0 commit comments

Comments
 (0)