Skip to content

Commit 29e6d66

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

File tree

6 files changed

+56
-1
lines changed

6 files changed

+56
-1
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
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
}
Lines changed: 10 additions & 0 deletions
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+
Lines changed: 10 additions & 0 deletions
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;
Lines changed: 9 additions & 0 deletions
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+
Lines changed: 21 additions & 0 deletions
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+
Lines changed: 5 additions & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy