Include export specifiers in the list of syntactic defaults (#24549) (#24578)

This commit is contained in:
Wesley Wigham
2018-06-01 12:16:01 -07:00
committed by GitHub
parent dfe8cab72c
commit 2dd189922f
5 changed files with 77 additions and 1 deletions

View File

@@ -1786,7 +1786,7 @@ namespace ts {
}
function isSyntacticDefault(node: Node) {
return ((isExportAssignment(node) && !node.isExportEquals) || hasModifier(node, ModifierFlags.Default));
return ((isExportAssignment(node) && !node.isExportEquals) || hasModifier(node, ModifierFlags.Default) || isExportSpecifier(node));
}
function canHaveSyntheticDefault(file: SourceFile | undefined, moduleSymbol: Symbol, dontResolveAlias: boolean) {

View File

@@ -0,0 +1,36 @@
//// [tests/cases/compiler/reexportDefaultIsCallable.ts] ////
//// [schema.d.ts]
export default class Schema {}
//// [reexporter.d.ts]
export { default } from "./schema";
//// [usage.ts]
import Base from "./reexporter";
export default class Mine extends Base {}
//// [usage.js]
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
exports.__esModule = true;
var reexporter_1 = __importDefault(require("./reexporter"));
var Mine = /** @class */ (function (_super) {
__extends(Mine, _super);
function Mine() {
return _super !== null && _super.apply(this, arguments) || this;
}
return Mine;
}(reexporter_1["default"]));
exports["default"] = Mine;

View File

@@ -0,0 +1,16 @@
=== tests/cases/compiler/schema.d.ts ===
export default class Schema {}
>Schema : Symbol(Schema, Decl(schema.d.ts, 0, 0))
=== tests/cases/compiler/reexporter.d.ts ===
export { default } from "./schema";
>default : Symbol(default, Decl(reexporter.d.ts, 0, 8))
=== tests/cases/compiler/usage.ts ===
import Base from "./reexporter";
>Base : Symbol(Base, Decl(usage.ts, 0, 6))
export default class Mine extends Base {}
>Mine : Symbol(Mine, Decl(usage.ts, 0, 32))
>Base : Symbol(Base, Decl(usage.ts, 0, 6))

View File

@@ -0,0 +1,16 @@
=== tests/cases/compiler/schema.d.ts ===
export default class Schema {}
>Schema : Schema
=== tests/cases/compiler/reexporter.d.ts ===
export { default } from "./schema";
>default : typeof import("tests/cases/compiler/schema").default
=== tests/cases/compiler/usage.ts ===
import Base from "./reexporter";
>Base : typeof Base
export default class Mine extends Base {}
>Mine : Mine
>Base : Base

View File

@@ -0,0 +1,8 @@
// @esModuleInterop: true
// @filename: schema.d.ts
export default class Schema {}
// @filename: reexporter.d.ts
export { default } from "./schema";
// @filename: usage.ts
import Base from "./reexporter";
export default class Mine extends Base {}