Dont consider global augmentation top-level members as having the export modifier (#23846)
* Dont consider global argumentation top-level members as having the export modifier * Remove unneeded test parts from repro
This commit is contained in:
parent
b467cd8a99
commit
19a985eb24
5 changed files with 82 additions and 1 deletions
|
@ -21319,7 +21319,7 @@ namespace ts {
|
|||
n.parent.kind !== SyntaxKind.ClassDeclaration &&
|
||||
n.parent.kind !== SyntaxKind.ClassExpression &&
|
||||
n.flags & NodeFlags.Ambient) {
|
||||
if (!(flags & ModifierFlags.Ambient)) {
|
||||
if (!(flags & ModifierFlags.Ambient) && !(isModuleBlock(n.parent) && isModuleDeclaration(n.parent.parent) && isGlobalScopeAugmentation(n.parent.parent))) {
|
||||
// It is nested in an ambient context, which means it is automatically exported
|
||||
flags |= ModifierFlags.Export;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
//// [tests/cases/compiler/globalFunctionAugmentationOverload.ts] ////
|
||||
|
||||
//// [mod.d.ts]
|
||||
declare function expect(spy: Function): void;
|
||||
declare module "mod" {
|
||||
class mod {}
|
||||
export = mod;
|
||||
}
|
||||
//// [mine.ts]
|
||||
import "mod";
|
||||
|
||||
declare global {
|
||||
function expect(element: string): void;
|
||||
}
|
||||
|
||||
//// [mine.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
require("mod");
|
|
@ -0,0 +1,25 @@
|
|||
=== tests/cases/compiler/mod.d.ts ===
|
||||
declare function expect(spy: Function): void;
|
||||
>expect : Symbol(expect, Decl(mod.d.ts, 0, 0), Decl(mine.ts, 2, 16))
|
||||
>spy : Symbol(spy, Decl(mod.d.ts, 0, 24))
|
||||
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
|
||||
declare module "mod" {
|
||||
>"mod" : Symbol("mod", Decl(mod.d.ts, 0, 45))
|
||||
|
||||
class mod {}
|
||||
>mod : Symbol(mod, Decl(mod.d.ts, 1, 22))
|
||||
|
||||
export = mod;
|
||||
>mod : Symbol(mod, Decl(mod.d.ts, 1, 22))
|
||||
}
|
||||
=== tests/cases/compiler/mine.ts ===
|
||||
import "mod";
|
||||
|
||||
declare global {
|
||||
>global : Symbol(global, Decl(mine.ts, 0, 13))
|
||||
|
||||
function expect(element: string): void;
|
||||
>expect : Symbol(expect, Decl(mod.d.ts, 0, 0), Decl(mine.ts, 2, 16))
|
||||
>element : Symbol(element, Decl(mine.ts, 3, 20))
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
=== tests/cases/compiler/mod.d.ts ===
|
||||
declare function expect(spy: Function): void;
|
||||
>expect : { (spy: Function): void; (element: string): void; }
|
||||
>spy : Function
|
||||
>Function : Function
|
||||
|
||||
declare module "mod" {
|
||||
>"mod" : typeof import("mod")
|
||||
|
||||
class mod {}
|
||||
>mod : mod
|
||||
|
||||
export = mod;
|
||||
>mod : mod
|
||||
}
|
||||
=== tests/cases/compiler/mine.ts ===
|
||||
import "mod";
|
||||
|
||||
declare global {
|
||||
>global : typeof global
|
||||
|
||||
function expect(element: string): void;
|
||||
>expect : { (spy: Function): void; (element: string): void; }
|
||||
>element : string
|
||||
}
|
12
tests/cases/compiler/globalFunctionAugmentationOverload.ts
Normal file
12
tests/cases/compiler/globalFunctionAugmentationOverload.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
// @filename: mod.d.ts
|
||||
declare function expect(spy: Function): void;
|
||||
declare module "mod" {
|
||||
class mod {}
|
||||
export = mod;
|
||||
}
|
||||
// @filename: mine.ts
|
||||
import "mod";
|
||||
|
||||
declare global {
|
||||
function expect(element: string): void;
|
||||
}
|
Loading…
Reference in a new issue