fix export * as default syntax (#39803)

* fix export * as default syntax

* update comments
This commit is contained in:
Wenlu Wang 2020-08-11 07:56:45 +08:00 committed by GitHub
parent 1ec71f0e0c
commit a80f60c6d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 1137 additions and 4 deletions

View File

@ -490,7 +490,7 @@ namespace ts {
*/
export function getLocalNameForExternalImport(factory: NodeFactory, node: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration, sourceFile: SourceFile): Identifier | undefined {
const namespaceDeclaration = getNamespaceDeclarationNode(node);
if (namespaceDeclaration && !isDefaultImport(node)) {
if (namespaceDeclaration && !isDefaultImport(node) && !isExportNamespaceAsDefaultDeclaration(node)) {
const name = namespaceDeclaration.name;
return isGeneratedIdentifier(name) ? name : factory.createIdentifier(getSourceTextOfNodeFromSourceFile(sourceFile, name) || idText(name));
}

View File

@ -6996,7 +6996,7 @@ namespace ts {
}
function parseNamespaceExport(pos: number): NamespaceExport {
return finishNode(factory.createNamespaceExport(parseIdentifier()), pos);
return finishNode(factory.createNamespaceExport(parseIdentifierName()), pos);
}
function parseExportDeclaration(pos: number, hasJSDoc: boolean, decorators: NodeArray<Decorator> | undefined, modifiers: NodeArray<Modifier> | undefined): ExportDeclaration {

View File

@ -99,7 +99,7 @@ namespace ts {
);
setOriginalNode(importDecl, node.exportClause);
const exportDecl = factory.createExportDeclaration(
const exportDecl = isExportNamespaceAsDefaultDeclaration(node) ? factory.createExportDefault(synthName) : factory.createExportDeclaration(
/*decorators*/ undefined,
/*modifiers*/ undefined,
/*isTypeOnly*/ false,

View File

@ -1043,6 +1043,7 @@ namespace ts {
else if (node.exportClause) {
const statements: Statement[] = [];
// export * as ns from "mod";
// export * as default from "mod";
statements.push(
setOriginalNode(
setTextRange(
@ -1051,7 +1052,8 @@ namespace ts {
factory.cloneNode(node.exportClause.name),
getHelperExpressionForExport(node, moduleKind !== ModuleKind.AMD ?
createRequireCall(node) :
factory.createIdentifier(idText(node.exportClause.name)))
isExportNamespaceAsDefaultDeclaration(node) ? generatedName :
factory.createIdentifier(idText(node.exportClause.name)))
)
),
node

View File

@ -519,6 +519,10 @@ namespace ts {
return !!findAncestor(node, isJSDocTypeExpression);
}
export function isExportNamespaceAsDefaultDeclaration(node: Node): boolean {
return !!(isExportDeclaration(node) && node.exportClause && isNamespaceExport(node.exportClause) && node.exportClause.name.escapedText === "default");
}
export function getTextOfNodeFromSourceText(sourceText: string, node: Node, includeTrivia = false): string {
if (nodeIsMissing(node)) {
return "";

View File

@ -0,0 +1,109 @@
//// [tests/cases/conformance/es2020/modules/exportAsNamespace4.ts] ////
//// [0.ts]
export const a = 1;
export const b = 2;
//// [1.ts]
export * as default from './0';
//// [11.ts]
import * as ns from './0';
export default ns;
//// [2.ts]
import foo from './1'
import foo1 from './11'
foo.a;
foo1.a;
foo.b;
foo1.b;
//// [0.js]
define(["require", "exports"], function (require, exports) {
"use strict";
exports.__esModule = true;
exports.b = exports.a = void 0;
exports.a = 1;
exports.b = 2;
});
//// [1.js]
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
define(["require", "exports", "./0"], function (require, exports, _0_1) {
"use strict";
exports.__esModule = true;
exports["default"] = void 0;
exports["default"] = __importStar(_0_1);
});
//// [11.js]
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
define(["require", "exports", "./0"], function (require, exports, ns) {
"use strict";
exports.__esModule = true;
ns = __importStar(ns);
exports["default"] = ns;
});
//// [2.js]
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
define(["require", "exports", "./1", "./11"], function (require, exports, _1_1, _11_1) {
"use strict";
exports.__esModule = true;
_1_1 = __importDefault(_1_1);
_11_1 = __importDefault(_11_1);
_1_1["default"].a;
_11_1["default"].a;
_1_1["default"].b;
_11_1["default"].b;
});
//// [0.d.ts]
export declare const a = 1;
export declare const b = 2;
//// [1.d.ts]
export * as default from './0';
//// [11.d.ts]
import * as ns from './0';
export default ns;
//// [2.d.ts]
export {};

View File

@ -0,0 +1,45 @@
=== tests/cases/conformance/es2020/modules/0.ts ===
export const a = 1;
>a : Symbol(a, Decl(0.ts, 0, 12))
export const b = 2;
>b : Symbol(b, Decl(0.ts, 1, 12))
=== tests/cases/conformance/es2020/modules/1.ts ===
export * as default from './0';
>default : Symbol(default, Decl(1.ts, 0, 6))
=== tests/cases/conformance/es2020/modules/11.ts ===
import * as ns from './0';
>ns : Symbol(ns, Decl(11.ts, 0, 6))
export default ns;
>ns : Symbol(ns, Decl(11.ts, 0, 6))
=== tests/cases/conformance/es2020/modules/2.ts ===
import foo from './1'
>foo : Symbol(foo, Decl(2.ts, 0, 6))
import foo1 from './11'
>foo1 : Symbol(foo1, Decl(2.ts, 1, 6))
foo.a;
>foo.a : Symbol(foo.a, Decl(0.ts, 0, 12))
>foo : Symbol(foo, Decl(2.ts, 0, 6))
>a : Symbol(foo.a, Decl(0.ts, 0, 12))
foo1.a;
>foo1.a : Symbol(foo.a, Decl(0.ts, 0, 12))
>foo1 : Symbol(foo1, Decl(2.ts, 1, 6))
>a : Symbol(foo.a, Decl(0.ts, 0, 12))
foo.b;
>foo.b : Symbol(foo.b, Decl(0.ts, 1, 12))
>foo : Symbol(foo, Decl(2.ts, 0, 6))
>b : Symbol(foo.b, Decl(0.ts, 1, 12))
foo1.b;
>foo1.b : Symbol(foo.b, Decl(0.ts, 1, 12))
>foo1 : Symbol(foo1, Decl(2.ts, 1, 6))
>b : Symbol(foo.b, Decl(0.ts, 1, 12))

View File

@ -0,0 +1,47 @@
=== tests/cases/conformance/es2020/modules/0.ts ===
export const a = 1;
>a : 1
>1 : 1
export const b = 2;
>b : 2
>2 : 2
=== tests/cases/conformance/es2020/modules/1.ts ===
export * as default from './0';
>default : typeof import("tests/cases/conformance/es2020/modules/0")
=== tests/cases/conformance/es2020/modules/11.ts ===
import * as ns from './0';
>ns : typeof ns
export default ns;
>ns : typeof ns
=== tests/cases/conformance/es2020/modules/2.ts ===
import foo from './1'
>foo : typeof foo
import foo1 from './11'
>foo1 : typeof foo
foo.a;
>foo.a : 1
>foo : typeof foo
>a : 1
foo1.a;
>foo1.a : 1
>foo1 : typeof foo
>a : 1
foo.b;
>foo.b : 2
>foo : typeof foo
>b : 2
foo1.b;
>foo1.b : 2
>foo1 : typeof foo
>b : 2

View File

@ -0,0 +1,101 @@
//// [tests/cases/conformance/es2020/modules/exportAsNamespace4.ts] ////
//// [0.ts]
export const a = 1;
export const b = 2;
//// [1.ts]
export * as default from './0';
//// [11.ts]
import * as ns from './0';
export default ns;
//// [2.ts]
import foo from './1'
import foo1 from './11'
foo.a;
foo1.a;
foo.b;
foo1.b;
//// [0.js]
"use strict";
exports.__esModule = true;
exports.b = exports.a = void 0;
exports.a = 1;
exports.b = 2;
//// [1.js]
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
exports.__esModule = true;
exports["default"] = void 0;
exports["default"] = __importStar(require("./0"));
//// [11.js]
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
exports.__esModule = true;
var ns = __importStar(require("./0"));
exports["default"] = ns;
//// [2.js]
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
exports.__esModule = true;
var _1_1 = __importDefault(require("./1"));
var _11_1 = __importDefault(require("./11"));
_1_1["default"].a;
_11_1["default"].a;
_1_1["default"].b;
_11_1["default"].b;
//// [0.d.ts]
export declare const a = 1;
export declare const b = 2;
//// [1.d.ts]
export * as default from './0';
//// [11.d.ts]
import * as ns from './0';
export default ns;
//// [2.d.ts]
export {};

View File

@ -0,0 +1,45 @@
=== tests/cases/conformance/es2020/modules/0.ts ===
export const a = 1;
>a : Symbol(a, Decl(0.ts, 0, 12))
export const b = 2;
>b : Symbol(b, Decl(0.ts, 1, 12))
=== tests/cases/conformance/es2020/modules/1.ts ===
export * as default from './0';
>default : Symbol(default, Decl(1.ts, 0, 6))
=== tests/cases/conformance/es2020/modules/11.ts ===
import * as ns from './0';
>ns : Symbol(ns, Decl(11.ts, 0, 6))
export default ns;
>ns : Symbol(ns, Decl(11.ts, 0, 6))
=== tests/cases/conformance/es2020/modules/2.ts ===
import foo from './1'
>foo : Symbol(foo, Decl(2.ts, 0, 6))
import foo1 from './11'
>foo1 : Symbol(foo1, Decl(2.ts, 1, 6))
foo.a;
>foo.a : Symbol(foo.a, Decl(0.ts, 0, 12))
>foo : Symbol(foo, Decl(2.ts, 0, 6))
>a : Symbol(foo.a, Decl(0.ts, 0, 12))
foo1.a;
>foo1.a : Symbol(foo.a, Decl(0.ts, 0, 12))
>foo1 : Symbol(foo1, Decl(2.ts, 1, 6))
>a : Symbol(foo.a, Decl(0.ts, 0, 12))
foo.b;
>foo.b : Symbol(foo.b, Decl(0.ts, 1, 12))
>foo : Symbol(foo, Decl(2.ts, 0, 6))
>b : Symbol(foo.b, Decl(0.ts, 1, 12))
foo1.b;
>foo1.b : Symbol(foo.b, Decl(0.ts, 1, 12))
>foo1 : Symbol(foo1, Decl(2.ts, 1, 6))
>b : Symbol(foo.b, Decl(0.ts, 1, 12))

View File

@ -0,0 +1,47 @@
=== tests/cases/conformance/es2020/modules/0.ts ===
export const a = 1;
>a : 1
>1 : 1
export const b = 2;
>b : 2
>2 : 2
=== tests/cases/conformance/es2020/modules/1.ts ===
export * as default from './0';
>default : typeof import("tests/cases/conformance/es2020/modules/0")
=== tests/cases/conformance/es2020/modules/11.ts ===
import * as ns from './0';
>ns : typeof ns
export default ns;
>ns : typeof ns
=== tests/cases/conformance/es2020/modules/2.ts ===
import foo from './1'
>foo : typeof foo
import foo1 from './11'
>foo1 : typeof foo
foo.a;
>foo.a : 1
>foo : typeof foo
>a : 1
foo1.a;
>foo1.a : 1
>foo1 : typeof foo
>a : 1
foo.b;
>foo.b : 2
>foo : typeof foo
>b : 2
foo1.b;
>foo1.b : 2
>foo1 : typeof foo
>b : 2

View File

@ -0,0 +1,51 @@
//// [tests/cases/conformance/es2020/modules/exportAsNamespace4.ts] ////
//// [0.ts]
export const a = 1;
export const b = 2;
//// [1.ts]
export * as default from './0';
//// [11.ts]
import * as ns from './0';
export default ns;
//// [2.ts]
import foo from './1'
import foo1 from './11'
foo.a;
foo1.a;
foo.b;
foo1.b;
//// [0.js]
export var a = 1;
export var b = 2;
//// [1.js]
import * as default_1 from './0';
export default default_1;
//// [11.js]
import * as ns from './0';
export default ns;
//// [2.js]
import foo from './1';
import foo1 from './11';
foo.a;
foo1.a;
foo.b;
foo1.b;
//// [0.d.ts]
export declare const a = 1;
export declare const b = 2;
//// [1.d.ts]
export * as default from './0';
//// [11.d.ts]
import * as ns from './0';
export default ns;
//// [2.d.ts]
export {};

View File

@ -0,0 +1,45 @@
=== tests/cases/conformance/es2020/modules/0.ts ===
export const a = 1;
>a : Symbol(a, Decl(0.ts, 0, 12))
export const b = 2;
>b : Symbol(b, Decl(0.ts, 1, 12))
=== tests/cases/conformance/es2020/modules/1.ts ===
export * as default from './0';
>default : Symbol(default, Decl(1.ts, 0, 6))
=== tests/cases/conformance/es2020/modules/11.ts ===
import * as ns from './0';
>ns : Symbol(ns, Decl(11.ts, 0, 6))
export default ns;
>ns : Symbol(ns, Decl(11.ts, 0, 6))
=== tests/cases/conformance/es2020/modules/2.ts ===
import foo from './1'
>foo : Symbol(foo, Decl(2.ts, 0, 6))
import foo1 from './11'
>foo1 : Symbol(foo1, Decl(2.ts, 1, 6))
foo.a;
>foo.a : Symbol(foo.a, Decl(0.ts, 0, 12))
>foo : Symbol(foo, Decl(2.ts, 0, 6))
>a : Symbol(foo.a, Decl(0.ts, 0, 12))
foo1.a;
>foo1.a : Symbol(foo.a, Decl(0.ts, 0, 12))
>foo1 : Symbol(foo1, Decl(2.ts, 1, 6))
>a : Symbol(foo.a, Decl(0.ts, 0, 12))
foo.b;
>foo.b : Symbol(foo.b, Decl(0.ts, 1, 12))
>foo : Symbol(foo, Decl(2.ts, 0, 6))
>b : Symbol(foo.b, Decl(0.ts, 1, 12))
foo1.b;
>foo1.b : Symbol(foo.b, Decl(0.ts, 1, 12))
>foo1 : Symbol(foo1, Decl(2.ts, 1, 6))
>b : Symbol(foo.b, Decl(0.ts, 1, 12))

View File

@ -0,0 +1,47 @@
=== tests/cases/conformance/es2020/modules/0.ts ===
export const a = 1;
>a : 1
>1 : 1
export const b = 2;
>b : 2
>2 : 2
=== tests/cases/conformance/es2020/modules/1.ts ===
export * as default from './0';
>default : typeof import("tests/cases/conformance/es2020/modules/0")
=== tests/cases/conformance/es2020/modules/11.ts ===
import * as ns from './0';
>ns : typeof ns
export default ns;
>ns : typeof ns
=== tests/cases/conformance/es2020/modules/2.ts ===
import foo from './1'
>foo : typeof foo
import foo1 from './11'
>foo1 : typeof foo
foo.a;
>foo.a : 1
>foo : typeof foo
>a : 1
foo1.a;
>foo1.a : 1
>foo1 : typeof foo
>a : 1
foo.b;
>foo.b : 2
>foo : typeof foo
>b : 2
foo1.b;
>foo1.b : 2
>foo1 : typeof foo
>b : 2

View File

@ -0,0 +1,50 @@
//// [tests/cases/conformance/es2020/modules/exportAsNamespace4.ts] ////
//// [0.ts]
export const a = 1;
export const b = 2;
//// [1.ts]
export * as default from './0';
//// [11.ts]
import * as ns from './0';
export default ns;
//// [2.ts]
import foo from './1'
import foo1 from './11'
foo.a;
foo1.a;
foo.b;
foo1.b;
//// [0.js]
export var a = 1;
export var b = 2;
//// [1.js]
export * as default from './0';
//// [11.js]
import * as ns from './0';
export default ns;
//// [2.js]
import foo from './1';
import foo1 from './11';
foo.a;
foo1.a;
foo.b;
foo1.b;
//// [0.d.ts]
export declare const a = 1;
export declare const b = 2;
//// [1.d.ts]
export * as default from './0';
//// [11.d.ts]
import * as ns from './0';
export default ns;
//// [2.d.ts]
export {};

View File

@ -0,0 +1,45 @@
=== tests/cases/conformance/es2020/modules/0.ts ===
export const a = 1;
>a : Symbol(a, Decl(0.ts, 0, 12))
export const b = 2;
>b : Symbol(b, Decl(0.ts, 1, 12))
=== tests/cases/conformance/es2020/modules/1.ts ===
export * as default from './0';
>default : Symbol(default, Decl(1.ts, 0, 6))
=== tests/cases/conformance/es2020/modules/11.ts ===
import * as ns from './0';
>ns : Symbol(ns, Decl(11.ts, 0, 6))
export default ns;
>ns : Symbol(ns, Decl(11.ts, 0, 6))
=== tests/cases/conformance/es2020/modules/2.ts ===
import foo from './1'
>foo : Symbol(foo, Decl(2.ts, 0, 6))
import foo1 from './11'
>foo1 : Symbol(foo1, Decl(2.ts, 1, 6))
foo.a;
>foo.a : Symbol(foo.a, Decl(0.ts, 0, 12))
>foo : Symbol(foo, Decl(2.ts, 0, 6))
>a : Symbol(foo.a, Decl(0.ts, 0, 12))
foo1.a;
>foo1.a : Symbol(foo.a, Decl(0.ts, 0, 12))
>foo1 : Symbol(foo1, Decl(2.ts, 1, 6))
>a : Symbol(foo.a, Decl(0.ts, 0, 12))
foo.b;
>foo.b : Symbol(foo.b, Decl(0.ts, 1, 12))
>foo : Symbol(foo, Decl(2.ts, 0, 6))
>b : Symbol(foo.b, Decl(0.ts, 1, 12))
foo1.b;
>foo1.b : Symbol(foo.b, Decl(0.ts, 1, 12))
>foo1 : Symbol(foo1, Decl(2.ts, 1, 6))
>b : Symbol(foo.b, Decl(0.ts, 1, 12))

View File

@ -0,0 +1,47 @@
=== tests/cases/conformance/es2020/modules/0.ts ===
export const a = 1;
>a : 1
>1 : 1
export const b = 2;
>b : 2
>2 : 2
=== tests/cases/conformance/es2020/modules/1.ts ===
export * as default from './0';
>default : typeof import("tests/cases/conformance/es2020/modules/0")
=== tests/cases/conformance/es2020/modules/11.ts ===
import * as ns from './0';
>ns : typeof ns
export default ns;
>ns : typeof ns
=== tests/cases/conformance/es2020/modules/2.ts ===
import foo from './1'
>foo : typeof foo
import foo1 from './11'
>foo1 : typeof foo
foo.a;
>foo.a : 1
>foo : typeof foo
>a : 1
foo1.a;
>foo1.a : 1
>foo1 : typeof foo
>a : 1
foo.b;
>foo.b : 2
>foo : typeof foo
>b : 2
foo1.b;
>foo1.b : 2
>foo1 : typeof foo
>b : 2

View File

@ -0,0 +1,100 @@
//// [tests/cases/conformance/es2020/modules/exportAsNamespace4.ts] ////
//// [0.ts]
export const a = 1;
export const b = 2;
//// [1.ts]
export * as default from './0';
//// [11.ts]
import * as ns from './0';
export default ns;
//// [2.ts]
import foo from './1'
import foo1 from './11'
foo.a;
foo1.a;
foo.b;
foo1.b;
//// [0.js]
System.register([], function (exports_1, context_1) {
"use strict";
var a, b;
var __moduleName = context_1 && context_1.id;
return {
setters: [],
execute: function () {
exports_1("a", a = 1);
exports_1("b", b = 2);
}
};
});
//// [1.js]
System.register(["./0"], function (exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
return {
setters: [
function (_0_1_1) {
exports_1("default", _0_1_1);
}
],
execute: function () {
}
};
});
//// [11.js]
System.register(["./0"], function (exports_1, context_1) {
"use strict";
var ns;
var __moduleName = context_1 && context_1.id;
return {
setters: [
function (ns_1) {
ns = ns_1;
}
],
execute: function () {
exports_1("default", ns);
}
};
});
//// [2.js]
System.register(["./1", "./11"], function (exports_1, context_1) {
"use strict";
var _1_1, _11_1;
var __moduleName = context_1 && context_1.id;
return {
setters: [
function (_1_1_1) {
_1_1 = _1_1_1;
},
function (_11_1_1) {
_11_1 = _11_1_1;
}
],
execute: function () {
_1_1["default"].a;
_11_1["default"].a;
_1_1["default"].b;
_11_1["default"].b;
}
};
});
//// [0.d.ts]
export declare const a = 1;
export declare const b = 2;
//// [1.d.ts]
export * as default from './0';
//// [11.d.ts]
import * as ns from './0';
export default ns;
//// [2.d.ts]
export {};

View File

@ -0,0 +1,45 @@
=== tests/cases/conformance/es2020/modules/0.ts ===
export const a = 1;
>a : Symbol(a, Decl(0.ts, 0, 12))
export const b = 2;
>b : Symbol(b, Decl(0.ts, 1, 12))
=== tests/cases/conformance/es2020/modules/1.ts ===
export * as default from './0';
>default : Symbol(default, Decl(1.ts, 0, 6))
=== tests/cases/conformance/es2020/modules/11.ts ===
import * as ns from './0';
>ns : Symbol(ns, Decl(11.ts, 0, 6))
export default ns;
>ns : Symbol(ns, Decl(11.ts, 0, 6))
=== tests/cases/conformance/es2020/modules/2.ts ===
import foo from './1'
>foo : Symbol(foo, Decl(2.ts, 0, 6))
import foo1 from './11'
>foo1 : Symbol(foo1, Decl(2.ts, 1, 6))
foo.a;
>foo.a : Symbol(foo.a, Decl(0.ts, 0, 12))
>foo : Symbol(foo, Decl(2.ts, 0, 6))
>a : Symbol(foo.a, Decl(0.ts, 0, 12))
foo1.a;
>foo1.a : Symbol(foo.a, Decl(0.ts, 0, 12))
>foo1 : Symbol(foo1, Decl(2.ts, 1, 6))
>a : Symbol(foo.a, Decl(0.ts, 0, 12))
foo.b;
>foo.b : Symbol(foo.b, Decl(0.ts, 1, 12))
>foo : Symbol(foo, Decl(2.ts, 0, 6))
>b : Symbol(foo.b, Decl(0.ts, 1, 12))
foo1.b;
>foo1.b : Symbol(foo.b, Decl(0.ts, 1, 12))
>foo1 : Symbol(foo1, Decl(2.ts, 1, 6))
>b : Symbol(foo.b, Decl(0.ts, 1, 12))

View File

@ -0,0 +1,47 @@
=== tests/cases/conformance/es2020/modules/0.ts ===
export const a = 1;
>a : 1
>1 : 1
export const b = 2;
>b : 2
>2 : 2
=== tests/cases/conformance/es2020/modules/1.ts ===
export * as default from './0';
>default : typeof import("tests/cases/conformance/es2020/modules/0")
=== tests/cases/conformance/es2020/modules/11.ts ===
import * as ns from './0';
>ns : typeof ns
export default ns;
>ns : typeof ns
=== tests/cases/conformance/es2020/modules/2.ts ===
import foo from './1'
>foo : typeof foo
import foo1 from './11'
>foo1 : typeof foo
foo.a;
>foo.a : 1
>foo : typeof foo
>a : 1
foo1.a;
>foo1.a : 1
>foo1 : typeof foo
>a : 1
foo.b;
>foo.b : 2
>foo : typeof foo
>b : 2
foo1.b;
>foo1.b : 2
>foo1 : typeof foo
>b : 2

View File

@ -0,0 +1,141 @@
//// [tests/cases/conformance/es2020/modules/exportAsNamespace4.ts] ////
//// [0.ts]
export const a = 1;
export const b = 2;
//// [1.ts]
export * as default from './0';
//// [11.ts]
import * as ns from './0';
export default ns;
//// [2.ts]
import foo from './1'
import foo1 from './11'
foo.a;
foo1.a;
foo.b;
foo1.b;
//// [0.js]
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
"use strict";
exports.__esModule = true;
exports.b = exports.a = void 0;
exports.a = 1;
exports.b = 2;
});
//// [1.js]
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "./0"], factory);
}
})(function (require, exports) {
"use strict";
exports.__esModule = true;
exports["default"] = void 0;
exports["default"] = __importStar(require("./0"));
});
//// [11.js]
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "./0"], factory);
}
})(function (require, exports) {
"use strict";
exports.__esModule = true;
var ns = __importStar(require("./0"));
exports["default"] = ns;
});
//// [2.js]
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "./1", "./11"], factory);
}
})(function (require, exports) {
"use strict";
exports.__esModule = true;
var _1_1 = __importDefault(require("./1"));
var _11_1 = __importDefault(require("./11"));
_1_1["default"].a;
_11_1["default"].a;
_1_1["default"].b;
_11_1["default"].b;
});
//// [0.d.ts]
export declare const a = 1;
export declare const b = 2;
//// [1.d.ts]
export * as default from './0';
//// [11.d.ts]
import * as ns from './0';
export default ns;
//// [2.d.ts]
export {};

View File

@ -0,0 +1,45 @@
=== tests/cases/conformance/es2020/modules/0.ts ===
export const a = 1;
>a : Symbol(a, Decl(0.ts, 0, 12))
export const b = 2;
>b : Symbol(b, Decl(0.ts, 1, 12))
=== tests/cases/conformance/es2020/modules/1.ts ===
export * as default from './0';
>default : Symbol(default, Decl(1.ts, 0, 6))
=== tests/cases/conformance/es2020/modules/11.ts ===
import * as ns from './0';
>ns : Symbol(ns, Decl(11.ts, 0, 6))
export default ns;
>ns : Symbol(ns, Decl(11.ts, 0, 6))
=== tests/cases/conformance/es2020/modules/2.ts ===
import foo from './1'
>foo : Symbol(foo, Decl(2.ts, 0, 6))
import foo1 from './11'
>foo1 : Symbol(foo1, Decl(2.ts, 1, 6))
foo.a;
>foo.a : Symbol(foo.a, Decl(0.ts, 0, 12))
>foo : Symbol(foo, Decl(2.ts, 0, 6))
>a : Symbol(foo.a, Decl(0.ts, 0, 12))
foo1.a;
>foo1.a : Symbol(foo.a, Decl(0.ts, 0, 12))
>foo1 : Symbol(foo1, Decl(2.ts, 1, 6))
>a : Symbol(foo.a, Decl(0.ts, 0, 12))
foo.b;
>foo.b : Symbol(foo.b, Decl(0.ts, 1, 12))
>foo : Symbol(foo, Decl(2.ts, 0, 6))
>b : Symbol(foo.b, Decl(0.ts, 1, 12))
foo1.b;
>foo1.b : Symbol(foo.b, Decl(0.ts, 1, 12))
>foo1 : Symbol(foo1, Decl(2.ts, 1, 6))
>b : Symbol(foo.b, Decl(0.ts, 1, 12))

View File

@ -0,0 +1,47 @@
=== tests/cases/conformance/es2020/modules/0.ts ===
export const a = 1;
>a : 1
>1 : 1
export const b = 2;
>b : 2
>2 : 2
=== tests/cases/conformance/es2020/modules/1.ts ===
export * as default from './0';
>default : typeof import("tests/cases/conformance/es2020/modules/0")
=== tests/cases/conformance/es2020/modules/11.ts ===
import * as ns from './0';
>ns : typeof ns
export default ns;
>ns : typeof ns
=== tests/cases/conformance/es2020/modules/2.ts ===
import foo from './1'
>foo : typeof foo
import foo1 from './11'
>foo1 : typeof foo
foo.a;
>foo.a : 1
>foo : typeof foo
>a : 1
foo1.a;
>foo1.a : 1
>foo1 : typeof foo
>a : 1
foo.b;
>foo.b : 2
>foo : typeof foo
>b : 2
foo1.b;
>foo1.b : 2
>foo1 : typeof foo
>b : 2

View File

@ -0,0 +1,23 @@
// @module: esnext, es2015, commonjs, amd, system, umd
// @filename: 0.ts
// @declaration: true
// @esModuleInterop: true
export const a = 1;
export const b = 2;
// @filename: 1.ts
export * as default from './0';
// @filename: 11.ts
import * as ns from './0';
export default ns;
// @filename: 2.ts
import foo from './1'
import foo1 from './11'
foo.a;
foo1.a;
foo.b;
foo1.b;