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:
Wesley Wigham 2018-05-03 11:21:11 -07:00 committed by GitHub
parent b467cd8a99
commit 19a985eb24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 82 additions and 1 deletions

View file

@ -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;
}

View file

@ -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");

View file

@ -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))
}

View file

@ -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
}

View 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;
}