Revert "Fix emit for `export { default } from ...` when both `importHelpers` …"
This reverts commit aa18962892
.
This commit is contained in:
Родитель
aa18962892
Коммит
0ee317e957
|
@ -68,7 +68,6 @@ import {
|
|||
map,
|
||||
MethodDeclaration,
|
||||
ModifierFlags,
|
||||
NamedExportBindings,
|
||||
NamedImportBindings,
|
||||
NamespaceExport,
|
||||
Node,
|
||||
|
@ -110,16 +109,14 @@ export interface ExternalModuleInfo {
|
|||
hasExportStarsToExportValues: boolean; // whether this module contains export*
|
||||
}
|
||||
|
||||
function containsDefaultReference(node: NamedImportBindings | NamedExportBindings | undefined) {
|
||||
function containsDefaultReference(node: NamedImportBindings | undefined) {
|
||||
if (!node) return false;
|
||||
if (!isNamedImports(node) && !isNamedExports(node)) return false;
|
||||
if (!isNamedImports(node)) return false;
|
||||
return some(node.elements, isNamedDefaultReference);
|
||||
}
|
||||
|
||||
function isNamedDefaultReference(e: ImportSpecifier | ExportSpecifier): boolean {
|
||||
return e.propertyName !== undefined ?
|
||||
e.propertyName.escapedText === InternalSymbolName.Default :
|
||||
e.name.escapedText === InternalSymbolName.Default;
|
||||
function isNamedDefaultReference(e: ImportSpecifier): boolean {
|
||||
return e.propertyName !== undefined && e.propertyName.escapedText === InternalSymbolName.Default;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
@ -219,7 +216,6 @@ export function collectExternalModuleInfo(context: TransformationContext, source
|
|||
externalImports.push(node as ExportDeclaration);
|
||||
if (isNamedExports((node as ExportDeclaration).exportClause!)) {
|
||||
addExportedNamesForExportDeclaration(node as ExportDeclaration);
|
||||
hasImportDefault ||= containsDefaultReference((node as ExportDeclaration).exportClause);
|
||||
}
|
||||
else {
|
||||
const name = ((node as ExportDeclaration).exportClause as NamespaceExport).name;
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
//// [tests/cases/compiler/importHelpersNoEmitHelpersExportDefault.ts] ////
|
||||
|
||||
//// [main.ts]
|
||||
// https://github.com/microsoft/TypeScript/issues/40328
|
||||
export { default as A } from "./other";
|
||||
|
||||
//// [main2.ts]
|
||||
export { default } from "./other";
|
||||
|
||||
//// [other.ts]
|
||||
export default {};
|
||||
|
||||
//// [tslib.d.ts]
|
||||
declare module "tslib" {
|
||||
function __importDefault(m: any): void;
|
||||
}
|
||||
|
||||
//// [other.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = {};
|
||||
//// [main.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.A = void 0;
|
||||
var tslib_1 = require("tslib");
|
||||
// https://github.com/microsoft/TypeScript/issues/40328
|
||||
var other_1 = require("./other");
|
||||
Object.defineProperty(exports, "A", { enumerable: true, get: function () { return tslib_1.__importDefault(other_1).default; } });
|
||||
//// [main2.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = void 0;
|
||||
var tslib_1 = require("tslib");
|
||||
var other_1 = require("./other");
|
||||
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(other_1).default; } });
|
|
@ -29,14 +29,16 @@ declare module "tslib" {
|
|||
|
||||
//// [index.js]
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.baz = exports.foo = exports.default = void 0;
|
||||
var tslib_1 = require("tslib");
|
||||
// cjs format file
|
||||
var fs_1 = require("fs");
|
||||
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(fs_1).default; } });
|
||||
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(fs_1).default; } });
|
||||
var fs_2 = require("fs");
|
||||
Object.defineProperty(exports, "foo", { enumerable: true, get: function () { return tslib_1.__importDefault(fs_2).default; } });
|
||||
Object.defineProperty(exports, "foo", { enumerable: true, get: function () { return __importDefault(fs_2).default; } });
|
||||
var fs_3 = require("fs");
|
||||
Object.defineProperty(exports, "baz", { enumerable: true, get: function () { return fs_3.bar; } });
|
||||
//// [index.js]
|
||||
|
|
|
@ -29,14 +29,16 @@ declare module "tslib" {
|
|||
|
||||
//// [index.js]
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.baz = exports.foo = exports.default = void 0;
|
||||
var tslib_1 = require("tslib");
|
||||
// cjs format file
|
||||
var fs_1 = require("fs");
|
||||
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(fs_1).default; } });
|
||||
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(fs_1).default; } });
|
||||
var fs_2 = require("fs");
|
||||
Object.defineProperty(exports, "foo", { enumerable: true, get: function () { return tslib_1.__importDefault(fs_2).default; } });
|
||||
Object.defineProperty(exports, "foo", { enumerable: true, get: function () { return __importDefault(fs_2).default; } });
|
||||
var fs_3 = require("fs");
|
||||
Object.defineProperty(exports, "baz", { enumerable: true, get: function () { return fs_3.bar; } });
|
||||
//// [index.js]
|
||||
|
|
|
@ -25,12 +25,14 @@ declare module "tslib" {
|
|||
|
||||
//// [index.js]
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = void 0;
|
||||
var tslib_1 = require("tslib");
|
||||
// cjs format file
|
||||
var fs_1 = require("fs");
|
||||
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(fs_1).default; } });
|
||||
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(fs_1).default; } });
|
||||
//// [index.js]
|
||||
// esm format file
|
||||
export { default } from "fs";
|
||||
|
|
|
@ -25,12 +25,14 @@ declare module "tslib" {
|
|||
|
||||
//// [index.js]
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = void 0;
|
||||
var tslib_1 = require("tslib");
|
||||
// cjs format file
|
||||
var fs_1 = require("fs");
|
||||
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return tslib_1.__importDefault(fs_1).default; } });
|
||||
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(fs_1).default; } });
|
||||
//// [index.js]
|
||||
// esm format file
|
||||
export { default } from "fs";
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
// @target: es5
|
||||
// @module: commonjs
|
||||
// @importHelpers: true
|
||||
// @noEmitHelpers: true
|
||||
// @esModuleInterop: true
|
||||
// @noTypesAndSymbols: true
|
||||
|
||||
// @filename: main.ts
|
||||
// https://github.com/microsoft/TypeScript/issues/40328
|
||||
export { default as A } from "./other";
|
||||
|
||||
// @filename: main2.ts
|
||||
export { default } from "./other";
|
||||
|
||||
// @filename: other.ts
|
||||
export default {};
|
||||
|
||||
// @filename: tslib.d.ts
|
||||
declare module "tslib" {
|
||||
function __importDefault(m: any): void;
|
||||
}
|
Загрузка…
Ссылка в новой задаче