mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Fix lib.includes('dom') check in containerSeemsToBeEmptyDomElement (#61481)
This commit is contained in:
parent
19b777260b
commit
29e6d6689d
@ -34454,7 +34454,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
|
||||
function containerSeemsToBeEmptyDomElement(containingType: Type) {
|
||||
return (compilerOptions.lib && !compilerOptions.lib.includes("dom")) &&
|
||||
return (compilerOptions.lib && !compilerOptions.lib.includes("lib.dom.d.ts")) &&
|
||||
everyContainedType(containingType, type => type.symbol && /^(?:EventTarget|Node|(?:HTML[a-zA-Z]*)?Element)$/.test(unescapeLeadingUnderscores(type.symbol.escapedName))) &&
|
||||
isEmptyObjectType(containingType);
|
||||
}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
missingDomElement_UsingDomLib.ts(3,37): error TS2339: Property 'textContent' does not exist on type 'HTMLMissingElement'.
|
||||
|
||||
|
||||
==== missingDomElement_UsingDomLib.ts (1 errors) ====
|
||||
interface HTMLMissingElement {}
|
||||
|
||||
(({}) as any as HTMLMissingElement).textContent;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2339: Property 'textContent' does not exist on type 'HTMLMissingElement'.
|
||||
|
||||
10
tests/baselines/reference/missingDomElement_UsingDomLib.js
Normal file
10
tests/baselines/reference/missingDomElement_UsingDomLib.js
Normal file
@ -0,0 +1,10 @@
|
||||
//// [tests/cases/compiler/missingDomElement_UsingDomLib.ts] ////
|
||||
|
||||
//// [missingDomElement_UsingDomLib.ts]
|
||||
interface HTMLMissingElement {}
|
||||
|
||||
(({}) as any as HTMLMissingElement).textContent;
|
||||
|
||||
|
||||
//// [missingDomElement_UsingDomLib.js]
|
||||
({}).textContent;
|
||||
@ -0,0 +1,9 @@
|
||||
//// [tests/cases/compiler/missingDomElement_UsingDomLib.ts] ////
|
||||
|
||||
=== missingDomElement_UsingDomLib.ts ===
|
||||
interface HTMLMissingElement {}
|
||||
>HTMLMissingElement : Symbol(HTMLMissingElement, Decl(missingDomElement_UsingDomLib.ts, 0, 0))
|
||||
|
||||
(({}) as any as HTMLMissingElement).textContent;
|
||||
>HTMLMissingElement : Symbol(HTMLMissingElement, Decl(missingDomElement_UsingDomLib.ts, 0, 0))
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
//// [tests/cases/compiler/missingDomElement_UsingDomLib.ts] ////
|
||||
|
||||
=== missingDomElement_UsingDomLib.ts ===
|
||||
interface HTMLMissingElement {}
|
||||
|
||||
(({}) as any as HTMLMissingElement).textContent;
|
||||
>(({}) as any as HTMLMissingElement).textContent : any
|
||||
> : ^^^
|
||||
>(({}) as any as HTMLMissingElement) : HTMLMissingElement
|
||||
> : ^^^^^^^^^^^^^^^^^^
|
||||
>({}) as any as HTMLMissingElement : HTMLMissingElement
|
||||
> : ^^^^^^^^^^^^^^^^^^
|
||||
>({}) as any : any
|
||||
> : ^^^
|
||||
>({}) : {}
|
||||
> : ^^
|
||||
>{} : {}
|
||||
> : ^^
|
||||
>textContent : any
|
||||
> : ^^^
|
||||
|
||||
5
tests/cases/compiler/missingDomElement_UsingDomLib.ts
Normal file
5
tests/cases/compiler/missingDomElement_UsingDomLib.ts
Normal file
@ -0,0 +1,5 @@
|
||||
// @lib: es5,dom
|
||||
|
||||
interface HTMLMissingElement {}
|
||||
|
||||
(({}) as any as HTMLMissingElement).textContent;
|
||||
Loading…
x
Reference in New Issue
Block a user