mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 19:59:23 -05:00
Skip ambient modules in globalThis (#48938)
* Skip ambient modules in globalThis
Previously, globalThis mistakenly included ambient modules, even though
these are not values:
```ts
declare module "ambientModule" {
export type typ = 1
export var val: typ
}
type Oops = (typeof globalThis)[\"ambientModule\"]
```
This PR adds ambient modules to the kinds of things that are skipped
when constructing `globalThis`' properties, along with block-scoped
variables.
* Skip only modules with every declaration ambient
The modules are required to have at least one declaration so that our
treatment of `globalThis` stays the same, and
`globalThis.globalThis.globalThis` remains legal.
This commit is contained in:
committed by
GitHub
parent
7d60dc1f5d
commit
46e8306050
@@ -11504,7 +11504,7 @@ namespace ts {
|
||||
if (symbol === globalThisSymbol) {
|
||||
const varsOnly = new Map<string, Symbol>() as SymbolTable;
|
||||
members.forEach(p => {
|
||||
if (!(p.flags & SymbolFlags.BlockScoped)) {
|
||||
if (!(p.flags & SymbolFlags.BlockScoped) && !(p.flags & SymbolFlags.ValueModule && p.declarations?.length && every(p.declarations, isAmbientModule))) {
|
||||
varsOnly.set(p.escapedName, p);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user