-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix declaration emit for imported export alias specifiers (#19852)
* Badness * Revert #3641, whose original bug has been fixed by other means * Add another repro
- Loading branch information
Showing
17 changed files
with
254 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tests/baselines/reference/declarationEmitOfTypeofAliasedExport.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//// [tests/cases/compiler/declarationEmitOfTypeofAliasedExport.ts] //// | ||
|
||
//// [a.ts] | ||
class C {} | ||
export { C as D } | ||
|
||
//// [b.ts] | ||
import * as a from "./a"; | ||
export default a.D; | ||
|
||
|
||
//// [a.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
var C = /** @class */ (function () { | ||
function C() { | ||
} | ||
return C; | ||
}()); | ||
exports.D = C; | ||
//// [b.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
var a = require("./a"); | ||
exports["default"] = a.D; | ||
|
||
|
||
//// [a.d.ts] | ||
declare class C { | ||
} | ||
export { C as D }; | ||
//// [b.d.ts] | ||
import * as a from "./a"; | ||
declare const _default: typeof a.D; | ||
export default _default; |
17 changes: 17 additions & 0 deletions
17
tests/baselines/reference/declarationEmitOfTypeofAliasedExport.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
=== /a.ts === | ||
class C {} | ||
>C : Symbol(C, Decl(a.ts, 0, 0)) | ||
|
||
export { C as D } | ||
>C : Symbol(D, Decl(a.ts, 1, 8)) | ||
>D : Symbol(D, Decl(a.ts, 1, 8)) | ||
|
||
=== /b.ts === | ||
import * as a from "./a"; | ||
>a : Symbol(a, Decl(b.ts, 0, 6)) | ||
|
||
export default a.D; | ||
>a.D : Symbol(a.D, Decl(a.ts, 1, 8)) | ||
>a : Symbol(a, Decl(b.ts, 0, 6)) | ||
>D : Symbol(a.D, Decl(a.ts, 1, 8)) | ||
|
17 changes: 17 additions & 0 deletions
17
tests/baselines/reference/declarationEmitOfTypeofAliasedExport.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
=== /a.ts === | ||
class C {} | ||
>C : C | ||
|
||
export { C as D } | ||
>C : typeof C | ||
>D : typeof C | ||
|
||
=== /b.ts === | ||
import * as a from "./a"; | ||
>a : typeof a | ||
|
||
export default a.D; | ||
>a.D : typeof a.D | ||
>a : typeof a | ||
>D : typeof a.D | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
tests/baselines/reference/exportSpecifierForAGlobal.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,3 @@ function f() { | |
return x; | ||
} | ||
exports.f = f; | ||
|
||
|
||
//// [b.d.ts] | ||
export { X }; | ||
export declare function f(): X; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
//// [tests/cases/compiler/reexportWrittenCorrectlyInDeclaration.ts] //// | ||
|
||
//// [ThingA.ts] | ||
// https://github.com/Microsoft/TypeScript/issues/8612 | ||
export class ThingA { } | ||
|
||
//// [ThingB.ts] | ||
export class ThingB { } | ||
|
||
//// [Things.ts] | ||
export {ThingA} from "./ThingA"; | ||
export {ThingB} from "./ThingB"; | ||
|
||
//// [Test.ts] | ||
import * as things from "./Things"; | ||
|
||
export class Test { | ||
public method = (input: things.ThingA) => { }; | ||
} | ||
|
||
//// [ThingA.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
// https://github.com/Microsoft/TypeScript/issues/8612 | ||
var ThingA = /** @class */ (function () { | ||
function ThingA() { | ||
} | ||
return ThingA; | ||
}()); | ||
exports.ThingA = ThingA; | ||
//// [ThingB.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
var ThingB = /** @class */ (function () { | ||
function ThingB() { | ||
} | ||
return ThingB; | ||
}()); | ||
exports.ThingB = ThingB; | ||
//// [Things.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
var ThingA_1 = require("./ThingA"); | ||
exports.ThingA = ThingA_1.ThingA; | ||
var ThingB_1 = require("./ThingB"); | ||
exports.ThingB = ThingB_1.ThingB; | ||
//// [Test.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
var Test = /** @class */ (function () { | ||
function Test() { | ||
this.method = function (input) { }; | ||
} | ||
return Test; | ||
}()); | ||
exports.Test = Test; | ||
|
||
|
||
//// [ThingA.d.ts] | ||
export declare class ThingA { | ||
} | ||
//// [ThingB.d.ts] | ||
export declare class ThingB { | ||
} | ||
//// [Things.d.ts] | ||
export { ThingA } from "./ThingA"; | ||
export { ThingB } from "./ThingB"; | ||
//// [Test.d.ts] | ||
import * as things from "./Things"; | ||
export declare class Test { | ||
method: (input: things.ThingA) => void; | ||
} |
29 changes: 29 additions & 0 deletions
29
tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
=== tests/cases/compiler/ThingA.ts === | ||
// https://github.com/Microsoft/TypeScript/issues/8612 | ||
export class ThingA { } | ||
>ThingA : Symbol(ThingA, Decl(ThingA.ts, 0, 0)) | ||
|
||
=== tests/cases/compiler/ThingB.ts === | ||
export class ThingB { } | ||
>ThingB : Symbol(ThingB, Decl(ThingB.ts, 0, 0)) | ||
|
||
=== tests/cases/compiler/Things.ts === | ||
export {ThingA} from "./ThingA"; | ||
>ThingA : Symbol(ThingA, Decl(Things.ts, 0, 8)) | ||
|
||
export {ThingB} from "./ThingB"; | ||
>ThingB : Symbol(ThingB, Decl(Things.ts, 1, 8)) | ||
|
||
=== tests/cases/compiler/Test.ts === | ||
import * as things from "./Things"; | ||
>things : Symbol(things, Decl(Test.ts, 0, 6)) | ||
|
||
export class Test { | ||
>Test : Symbol(Test, Decl(Test.ts, 0, 35)) | ||
|
||
public method = (input: things.ThingA) => { }; | ||
>method : Symbol(Test.method, Decl(Test.ts, 2, 19)) | ||
>input : Symbol(input, Decl(Test.ts, 3, 21)) | ||
>things : Symbol(things, Decl(Test.ts, 0, 6)) | ||
>ThingA : Symbol(things.ThingA, Decl(Things.ts, 0, 8)) | ||
} |
30 changes: 30 additions & 0 deletions
30
tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
=== tests/cases/compiler/ThingA.ts === | ||
// https://github.com/Microsoft/TypeScript/issues/8612 | ||
export class ThingA { } | ||
>ThingA : ThingA | ||
|
||
=== tests/cases/compiler/ThingB.ts === | ||
export class ThingB { } | ||
>ThingB : ThingB | ||
|
||
=== tests/cases/compiler/Things.ts === | ||
export {ThingA} from "./ThingA"; | ||
>ThingA : typeof ThingA | ||
|
||
export {ThingB} from "./ThingB"; | ||
>ThingB : typeof ThingB | ||
|
||
=== tests/cases/compiler/Test.ts === | ||
import * as things from "./Things"; | ||
>things : typeof things | ||
|
||
export class Test { | ||
>Test : Test | ||
|
||
public method = (input: things.ThingA) => { }; | ||
>method : (input: things.ThingA) => void | ||
>(input: things.ThingA) => { } : (input: things.ThingA) => void | ||
>input : things.ThingA | ||
>things : any | ||
>ThingA : things.ThingA | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// @declaration: true | ||
// @filename: /a.ts | ||
class C {} | ||
export { C as D } | ||
|
||
// @filename: /b.ts | ||
import * as a from "./a"; | ||
export default a.D; |
18 changes: 18 additions & 0 deletions
18
tests/cases/compiler/reexportWrittenCorrectlyInDeclaration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// https://github.com/Microsoft/TypeScript/issues/8612 | ||
// @declaration: true | ||
// @filename: ThingA.ts | ||
export class ThingA { } | ||
|
||
// @filename: ThingB.ts | ||
export class ThingB { } | ||
|
||
// @filename: Things.ts | ||
export {ThingA} from "./ThingA"; | ||
export {ThingB} from "./ThingB"; | ||
|
||
// @filename: Test.ts | ||
import * as things from "./Things"; | ||
|
||
export class Test { | ||
public method = (input: things.ThingA) => { }; | ||
} |