Properly determine whether an augmentation is a ValueModule or NamespaceModule
This commit is contained in:
parent
5c71de103a
commit
157a9b02fc
|
@ -1509,7 +1509,7 @@ namespace ts {
|
|||
errorOnFirstToken(node, Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible);
|
||||
}
|
||||
if (isExternalModuleAugmentation(node)) {
|
||||
declareSymbolAndAddToSymbolTable(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes);
|
||||
declareModuleSymbol(node);
|
||||
}
|
||||
else {
|
||||
let pattern: Pattern | undefined;
|
||||
|
@ -1531,12 +1531,8 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
else {
|
||||
const state = getModuleInstanceState(node);
|
||||
if (state === ModuleInstanceState.NonInstantiated) {
|
||||
declareSymbolAndAddToSymbolTable(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes);
|
||||
}
|
||||
else {
|
||||
declareSymbolAndAddToSymbolTable(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes);
|
||||
const state = declareModuleSymbol(node);
|
||||
if (state !== ModuleInstanceState.NonInstantiated) {
|
||||
if (node.symbol.flags & (SymbolFlags.Function | SymbolFlags.Class | SymbolFlags.RegularEnum)) {
|
||||
// if module was already merged with some function, class or non-const enum
|
||||
// treat is a non-const-enum-only
|
||||
|
@ -1557,6 +1553,15 @@ namespace ts {
|
|||
}
|
||||
}
|
||||
|
||||
function declareModuleSymbol(node: ModuleDeclaration): ModuleInstanceState {
|
||||
const state = getModuleInstanceState(node);
|
||||
const instantiated = state !== ModuleInstanceState.NonInstantiated;
|
||||
declareSymbolAndAddToSymbolTable(node,
|
||||
instantiated ? SymbolFlags.ValueModule : SymbolFlags.NamespaceModule,
|
||||
instantiated ? SymbolFlags.ValueModuleExcludes : SymbolFlags.NamespaceModuleExcludes);
|
||||
return state;
|
||||
}
|
||||
|
||||
function bindFunctionOrConstructorType(node: SignatureDeclaration): void {
|
||||
// For a given function symbol "<...>(...) => T" we want to generate a symbol identical
|
||||
// to the one we would get for: { <...>(...): T }
|
||||
|
|
22
tests/baselines/reference/augmentExportEquals7.errors.txt
Normal file
22
tests/baselines/reference/augmentExportEquals7.errors.txt
Normal file
|
@ -0,0 +1,22 @@
|
|||
/node_modules/@types/lib-extender/index.d.ts(2,16): error TS2300: Duplicate identifier '"lib"'.
|
||||
/node_modules/lib/index.d.ts(1,13): error TS2300: Duplicate identifier '"lib"'.
|
||||
/node_modules/lib/index.d.ts(2,19): error TS2300: Duplicate identifier '"lib"'.
|
||||
|
||||
|
||||
==== /node_modules/lib/index.d.ts (2 errors) ====
|
||||
declare var lib: () => void;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier '"lib"'.
|
||||
declare namespace lib {}
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier '"lib"'.
|
||||
export = lib;
|
||||
|
||||
==== /node_modules/@types/lib-extender/index.d.ts (1 errors) ====
|
||||
import * as lib from "lib";
|
||||
declare module "lib" {
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier '"lib"'.
|
||||
export function fn(): void;
|
||||
}
|
||||
|
10
tests/cases/compiler/augmentExportEquals7.ts
Normal file
10
tests/cases/compiler/augmentExportEquals7.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
// @Filename: /node_modules/lib/index.d.ts
|
||||
declare var lib: () => void;
|
||||
declare namespace lib {}
|
||||
export = lib;
|
||||
|
||||
// @Filename: /node_modules/@types/lib-extender/index.d.ts
|
||||
import * as lib from "lib";
|
||||
declare module "lib" {
|
||||
export function fn(): void;
|
||||
}
|
Loading…
Reference in a new issue