From b811b9f94b23491f1549eb11c20e272bdb7acb3d Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Mon, 11 Jan 2016 14:48:57 -0800 Subject: [PATCH] report errors when re-exporting globals --- src/compiler/checker.ts | 11 +++- src/compiler/diagnosticMessages.json | 4 ++ .../exportSpecifierForAGlobal.errors.txt | 16 ++++++ .../exportSpecifierForAGlobal.symbols | 20 ------- .../reference/exportSpecifierForAGlobal.types | 20 ------- ...ierReferencingOuterDeclaration1.errors.txt | 11 ++++ ...cifierReferencingOuterDeclaration1.symbols | 14 ----- ...pecifierReferencingOuterDeclaration1.types | 14 ----- ...ierReferencingOuterDeclaration2.errors.txt | 11 ++++ ...cifierReferencingOuterDeclaration2.symbols | 14 ----- ...pecifierReferencingOuterDeclaration2.types | 14 ----- .../reExportGlobalDeclaration1.errors.txt | 57 +++++++++++++++++++ .../reference/reExportGlobalDeclaration1.js | 24 ++++++++ .../reExportGlobalDeclaration2.errors.txt | 35 ++++++++++++ .../reference/reExportGlobalDeclaration2.js | 20 +++++++ .../reExportGlobalDeclaration3.errors.txt | 35 ++++++++++++ .../reference/reExportGlobalDeclaration3.js | 20 +++++++ .../reExportGlobalDeclaration4.errors.txt | 35 ++++++++++++ .../reference/reExportGlobalDeclaration4.js | 20 +++++++ .../compiler/reExportGlobalDeclaration1.ts | 19 +++++++ .../compiler/reExportGlobalDeclaration2.ts | 16 ++++++ .../compiler/reExportGlobalDeclaration3.ts | 16 ++++++ .../compiler/reExportGlobalDeclaration4.ts | 16 ++++++ 23 files changed, 365 insertions(+), 97 deletions(-) create mode 100644 tests/baselines/reference/exportSpecifierForAGlobal.errors.txt delete mode 100644 tests/baselines/reference/exportSpecifierForAGlobal.symbols delete mode 100644 tests/baselines/reference/exportSpecifierForAGlobal.types create mode 100644 tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.errors.txt delete mode 100644 tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.symbols delete mode 100644 tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.types create mode 100644 tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.errors.txt delete mode 100644 tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.symbols delete mode 100644 tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.types create mode 100644 tests/baselines/reference/reExportGlobalDeclaration1.errors.txt create mode 100644 tests/baselines/reference/reExportGlobalDeclaration1.js create mode 100644 tests/baselines/reference/reExportGlobalDeclaration2.errors.txt create mode 100644 tests/baselines/reference/reExportGlobalDeclaration2.js create mode 100644 tests/baselines/reference/reExportGlobalDeclaration3.errors.txt create mode 100644 tests/baselines/reference/reExportGlobalDeclaration3.js create mode 100644 tests/baselines/reference/reExportGlobalDeclaration4.errors.txt create mode 100644 tests/baselines/reference/reExportGlobalDeclaration4.js create mode 100644 tests/cases/compiler/reExportGlobalDeclaration1.ts create mode 100644 tests/cases/compiler/reExportGlobalDeclaration2.ts create mode 100644 tests/cases/compiler/reExportGlobalDeclaration3.ts create mode 100644 tests/cases/compiler/reExportGlobalDeclaration4.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7ed9dbcd37..5a6c8e121f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14364,7 +14364,16 @@ namespace ts { function checkExportSpecifier(node: ExportSpecifier) { checkAliasSymbol(node); if (!(node.parent.parent).moduleSpecifier) { - markExportAsReferenced(node); + const exportedName = node.propertyName || node.name; + // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) + const symbol = resolveName(exportedName, exportedName.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, + /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + if (symbol && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0]))) { + error(exportedName, Diagnostics.Cannot_re_export_name_that_is_not_defined_in_the_module); + } + else { + markExportAsReferenced(node); + } } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index a57c16e2cd..28b10dd73b 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1771,6 +1771,10 @@ "category": "Error", "code": 2660 }, + "Cannot re-export name that is not defined in the module.": { + "category": "Error", + "code": 2661 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 diff --git a/tests/baselines/reference/exportSpecifierForAGlobal.errors.txt b/tests/baselines/reference/exportSpecifierForAGlobal.errors.txt new file mode 100644 index 0000000000..6df9c6de1e --- /dev/null +++ b/tests/baselines/reference/exportSpecifierForAGlobal.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/b.ts(1,9): error TS2661: Cannot re-export name that is not defined in the module. + + +==== tests/cases/compiler/a.d.ts (0 errors) ==== + + declare class X { } + +==== tests/cases/compiler/b.ts (1 errors) ==== + export {X}; + ~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + export function f() { + var x: X; + return x; + } + \ No newline at end of file diff --git a/tests/baselines/reference/exportSpecifierForAGlobal.symbols b/tests/baselines/reference/exportSpecifierForAGlobal.symbols deleted file mode 100644 index b38fc7be27..0000000000 --- a/tests/baselines/reference/exportSpecifierForAGlobal.symbols +++ /dev/null @@ -1,20 +0,0 @@ -=== tests/cases/compiler/a.d.ts === - -declare class X { } ->X : Symbol(X, Decl(a.d.ts, 0, 0)) - -=== tests/cases/compiler/b.ts === -export {X}; ->X : Symbol(X, Decl(b.ts, 0, 8)) - -export function f() { ->f : Symbol(f, Decl(b.ts, 0, 11)) - - var x: X; ->x : Symbol(x, Decl(b.ts, 2, 7)) ->X : Symbol(X, Decl(a.d.ts, 0, 0)) - - return x; ->x : Symbol(x, Decl(b.ts, 2, 7)) -} - diff --git a/tests/baselines/reference/exportSpecifierForAGlobal.types b/tests/baselines/reference/exportSpecifierForAGlobal.types deleted file mode 100644 index e3d728ad0d..0000000000 --- a/tests/baselines/reference/exportSpecifierForAGlobal.types +++ /dev/null @@ -1,20 +0,0 @@ -=== tests/cases/compiler/a.d.ts === - -declare class X { } ->X : X - -=== tests/cases/compiler/b.ts === -export {X}; ->X : typeof X - -export function f() { ->f : () => X - - var x: X; ->x : X ->X : X - - return x; ->x : X -} - diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.errors.txt b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.errors.txt new file mode 100644 index 0000000000..7eb095b05f --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/exportSpecifierReferencingOuterDeclaration1.ts(3,14): error TS2661: Cannot re-export name that is not defined in the module. + + +==== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration1.ts (1 errors) ==== + declare module X { export interface bar { } } + declare module "m" { + export { X }; + ~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + export function foo(): X.bar; + } \ No newline at end of file diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.symbols b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.symbols deleted file mode 100644 index 16abde86d3..0000000000 --- a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.symbols +++ /dev/null @@ -1,14 +0,0 @@ -=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration1.ts === -declare module X { export interface bar { } } ->X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 0, 0)) ->bar : Symbol(bar, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 0, 18)) - -declare module "m" { - export { X }; ->X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 2, 12)) - - export function foo(): X.bar; ->foo : Symbol(foo, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 2, 17)) ->X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 0, 0)) ->bar : Symbol(X.bar, Decl(exportSpecifierReferencingOuterDeclaration1.ts, 0, 18)) -} diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.types b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.types deleted file mode 100644 index be03554a1b..0000000000 --- a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration1.types +++ /dev/null @@ -1,14 +0,0 @@ -=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration1.ts === -declare module X { export interface bar { } } ->X : any ->bar : bar - -declare module "m" { - export { X }; ->X : any - - export function foo(): X.bar; ->foo : () => X.bar ->X : any ->bar : X.bar -} diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.errors.txt b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.errors.txt new file mode 100644 index 0000000000..0011801078 --- /dev/null +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_B.ts(1,10): error TS2661: Cannot re-export name that is not defined in the module. + + +==== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_A.ts (0 errors) ==== + declare module X { export interface bar { } } + +==== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_B.ts (1 errors) ==== + export { X }; + ~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + export declare function foo(): X.bar; \ No newline at end of file diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.symbols b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.symbols deleted file mode 100644 index 9a57645b1c..0000000000 --- a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.symbols +++ /dev/null @@ -1,14 +0,0 @@ -=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_A.ts === -declare module X { export interface bar { } } ->X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration2_A.ts, 0, 0)) ->bar : Symbol(bar, Decl(exportSpecifierReferencingOuterDeclaration2_A.ts, 0, 18)) - -=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_B.ts === -export { X }; ->X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration2_B.ts, 0, 8)) - -export declare function foo(): X.bar; ->foo : Symbol(foo, Decl(exportSpecifierReferencingOuterDeclaration2_B.ts, 0, 13)) ->X : Symbol(X, Decl(exportSpecifierReferencingOuterDeclaration2_A.ts, 0, 0)) ->bar : Symbol(X.bar, Decl(exportSpecifierReferencingOuterDeclaration2_A.ts, 0, 18)) - diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.types b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.types deleted file mode 100644 index fa59948c11..0000000000 --- a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration2.types +++ /dev/null @@ -1,14 +0,0 @@ -=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_A.ts === -declare module X { export interface bar { } } ->X : any ->bar : bar - -=== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_B.ts === -export { X }; ->X : any - -export declare function foo(): X.bar; ->foo : () => X.bar ->X : any ->bar : X.bar - diff --git a/tests/baselines/reference/reExportGlobalDeclaration1.errors.txt b/tests/baselines/reference/reExportGlobalDeclaration1.errors.txt new file mode 100644 index 0000000000..0ebeed05b2 --- /dev/null +++ b/tests/baselines/reference/reExportGlobalDeclaration1.errors.txt @@ -0,0 +1,57 @@ +tests/cases/compiler/file2.ts(1,9): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(1,12): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(2,9): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(2,13): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(4,9): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(4,12): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(5,9): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(5,12): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(8,9): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(9,9): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(10,9): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(11,9): error TS2661: Cannot re-export name that is not defined in the module. + + +==== tests/cases/compiler/file1.d.ts (0 errors) ==== + + declare var x: number; + declare var x1: number; + declare let {a, b}: {a: number, b: number}; + +==== tests/cases/compiler/file2.ts (12 errors) ==== + export {x, x as y}; + ~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + ~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + export {x1, x1 as y1}; + ~~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + ~~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + + export {a, a as a1}; + ~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + ~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + export {b, b as b1}; + ~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + ~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + + + export {x as z}; + ~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + export {x1 as z1}; + ~~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + export {a as a2}; + ~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + export {b as b2}; + ~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + \ No newline at end of file diff --git a/tests/baselines/reference/reExportGlobalDeclaration1.js b/tests/baselines/reference/reExportGlobalDeclaration1.js new file mode 100644 index 0000000000..c0db9a0eaf --- /dev/null +++ b/tests/baselines/reference/reExportGlobalDeclaration1.js @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/reExportGlobalDeclaration1.ts] //// + +//// [file1.d.ts] + +declare var x: number; +declare var x1: number; +declare let {a, b}: {a: number, b: number}; + +//// [file2.ts] +export {x, x as y}; +export {x1, x1 as y1}; + +export {a, a as a1}; +export {b, b as b1}; + + +export {x as z}; +export {x1 as z1}; +export {a as a2}; +export {b as b2}; + + +//// [file2.js] +"use strict"; diff --git a/tests/baselines/reference/reExportGlobalDeclaration2.errors.txt b/tests/baselines/reference/reExportGlobalDeclaration2.errors.txt new file mode 100644 index 0000000000..17a3e2ad56 --- /dev/null +++ b/tests/baselines/reference/reExportGlobalDeclaration2.errors.txt @@ -0,0 +1,35 @@ +tests/cases/compiler/file2.ts(1,9): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(1,13): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(2,9): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(2,13): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(3,9): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(4,9): error TS2661: Cannot re-export name that is not defined in the module. + + +==== tests/cases/compiler/file1.d.ts (0 errors) ==== + + declare interface I1 { + x: number + } + + declare interface I2 { + x: number + } + +==== tests/cases/compiler/file2.ts (6 errors) ==== + export {I1, I1 as II1}; + ~~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + ~~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + export {I2, I2 as II2}; + ~~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + ~~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + export {I1 as III1}; + ~~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + export {I2 as III2}; + ~~ +!!! error TS2661: Cannot re-export name that is not defined in the module. \ No newline at end of file diff --git a/tests/baselines/reference/reExportGlobalDeclaration2.js b/tests/baselines/reference/reExportGlobalDeclaration2.js new file mode 100644 index 0000000000..160a9b28f5 --- /dev/null +++ b/tests/baselines/reference/reExportGlobalDeclaration2.js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/reExportGlobalDeclaration2.ts] //// + +//// [file1.d.ts] + +declare interface I1 { + x: number +} + +declare interface I2 { + x: number +} + +//// [file2.ts] +export {I1, I1 as II1}; +export {I2, I2 as II2}; +export {I1 as III1}; +export {I2 as III2}; + +//// [file2.js] +"use strict"; diff --git a/tests/baselines/reference/reExportGlobalDeclaration3.errors.txt b/tests/baselines/reference/reExportGlobalDeclaration3.errors.txt new file mode 100644 index 0000000000..d99c184518 --- /dev/null +++ b/tests/baselines/reference/reExportGlobalDeclaration3.errors.txt @@ -0,0 +1,35 @@ +tests/cases/compiler/file2.ts(1,9): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(1,14): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(2,9): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(2,14): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(3,9): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(4,9): error TS2661: Cannot re-export name that is not defined in the module. + + +==== tests/cases/compiler/file1.d.ts (0 errors) ==== + + declare namespace NS1 { + export var foo: number; + } + + declare namespace NS2 { + export var foo: number; + } + +==== tests/cases/compiler/file2.ts (6 errors) ==== + export {NS1, NS1 as NNS1}; + ~~~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + ~~~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + export {NS2, NS2 as NNS2}; + ~~~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + ~~~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + export {NS1 as NNNS1}; + ~~~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + export {NS2 as NNNS2}; + ~~~ +!!! error TS2661: Cannot re-export name that is not defined in the module. \ No newline at end of file diff --git a/tests/baselines/reference/reExportGlobalDeclaration3.js b/tests/baselines/reference/reExportGlobalDeclaration3.js new file mode 100644 index 0000000000..e1b85b6b8d --- /dev/null +++ b/tests/baselines/reference/reExportGlobalDeclaration3.js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/reExportGlobalDeclaration3.ts] //// + +//// [file1.d.ts] + +declare namespace NS1 { + export var foo: number; +} + +declare namespace NS2 { + export var foo: number; +} + +//// [file2.ts] +export {NS1, NS1 as NNS1}; +export {NS2, NS2 as NNS2}; +export {NS1 as NNNS1}; +export {NS2 as NNNS2}; + +//// [file2.js] +"use strict"; diff --git a/tests/baselines/reference/reExportGlobalDeclaration4.errors.txt b/tests/baselines/reference/reExportGlobalDeclaration4.errors.txt new file mode 100644 index 0000000000..5e250a5fc5 --- /dev/null +++ b/tests/baselines/reference/reExportGlobalDeclaration4.errors.txt @@ -0,0 +1,35 @@ +tests/cases/compiler/file2.ts(1,9): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(1,15): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(2,9): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(2,15): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(3,9): error TS2661: Cannot re-export name that is not defined in the module. +tests/cases/compiler/file2.ts(4,9): error TS2661: Cannot re-export name that is not defined in the module. + + +==== tests/cases/compiler/file1.d.ts (0 errors) ==== + + declare class Cls1 { + x: number + } + declare class Cls2 { + x: number + } + + +==== tests/cases/compiler/file2.ts (6 errors) ==== + export {Cls1, Cls1 as CCls1}; + ~~~~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + ~~~~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + export {Cls2, Cls2 as CCls2}; + ~~~~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + ~~~~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + export {Cls1 as CCCls1}; + ~~~~ +!!! error TS2661: Cannot re-export name that is not defined in the module. + export {Cls2 as CCCls2}; + ~~~~ +!!! error TS2661: Cannot re-export name that is not defined in the module. \ No newline at end of file diff --git a/tests/baselines/reference/reExportGlobalDeclaration4.js b/tests/baselines/reference/reExportGlobalDeclaration4.js new file mode 100644 index 0000000000..09d6b76079 --- /dev/null +++ b/tests/baselines/reference/reExportGlobalDeclaration4.js @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/reExportGlobalDeclaration4.ts] //// + +//// [file1.d.ts] + +declare class Cls1 { + x: number +} +declare class Cls2 { + x: number +} + + +//// [file2.ts] +export {Cls1, Cls1 as CCls1}; +export {Cls2, Cls2 as CCls2}; +export {Cls1 as CCCls1}; +export {Cls2 as CCCls2}; + +//// [file2.js] +"use strict"; diff --git a/tests/cases/compiler/reExportGlobalDeclaration1.ts b/tests/cases/compiler/reExportGlobalDeclaration1.ts new file mode 100644 index 0000000000..9b3f0c030d --- /dev/null +++ b/tests/cases/compiler/reExportGlobalDeclaration1.ts @@ -0,0 +1,19 @@ +// @module: commonjs + +// @filename: file1.d.ts +declare var x: number; +declare var x1: number; +declare let {a, b}: {a: number, b: number}; + +// @filename: file2.ts +export {x, x as y}; +export {x1, x1 as y1}; + +export {a, a as a1}; +export {b, b as b1}; + + +export {x as z}; +export {x1 as z1}; +export {a as a2}; +export {b as b2}; diff --git a/tests/cases/compiler/reExportGlobalDeclaration2.ts b/tests/cases/compiler/reExportGlobalDeclaration2.ts new file mode 100644 index 0000000000..4dba4fd20f --- /dev/null +++ b/tests/cases/compiler/reExportGlobalDeclaration2.ts @@ -0,0 +1,16 @@ +// @module: commonjs + +// @filename: file1.d.ts +declare interface I1 { + x: number +} + +declare interface I2 { + x: number +} + +// @filename: file2.ts +export {I1, I1 as II1}; +export {I2, I2 as II2}; +export {I1 as III1}; +export {I2 as III2}; \ No newline at end of file diff --git a/tests/cases/compiler/reExportGlobalDeclaration3.ts b/tests/cases/compiler/reExportGlobalDeclaration3.ts new file mode 100644 index 0000000000..dc188ac6fb --- /dev/null +++ b/tests/cases/compiler/reExportGlobalDeclaration3.ts @@ -0,0 +1,16 @@ +// @module: commonjs + +// @filename: file1.d.ts +declare namespace NS1 { + export var foo: number; +} + +declare namespace NS2 { + export var foo: number; +} + +// @filename: file2.ts +export {NS1, NS1 as NNS1}; +export {NS2, NS2 as NNS2}; +export {NS1 as NNNS1}; +export {NS2 as NNNS2}; \ No newline at end of file diff --git a/tests/cases/compiler/reExportGlobalDeclaration4.ts b/tests/cases/compiler/reExportGlobalDeclaration4.ts new file mode 100644 index 0000000000..7298aa682f --- /dev/null +++ b/tests/cases/compiler/reExportGlobalDeclaration4.ts @@ -0,0 +1,16 @@ +// @module: commonjs + +// @filename: file1.d.ts +declare class Cls1 { + x: number +} +declare class Cls2 { + x: number +} + + +// @filename: file2.ts +export {Cls1, Cls1 as CCls1}; +export {Cls2, Cls2 as CCls2}; +export {Cls1 as CCCls1}; +export {Cls2 as CCCls2}; \ No newline at end of file