mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
isolatedModules does not imply every file is a module (#54218)
This commit is contained in:
@@ -1857,7 +1857,7 @@ function isCommonJSContainingModuleKind(kind: ModuleKind) {
|
||||
|
||||
/** @internal */
|
||||
export function isEffectiveExternalModule(node: SourceFile, compilerOptions: CompilerOptions) {
|
||||
return isExternalModule(node) || getIsolatedModules(compilerOptions) || (isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator);
|
||||
return isExternalModule(node) || (isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -130,7 +130,7 @@ var x = 0;`, {
|
||||
testVerbatimModuleSyntax: true
|
||||
});
|
||||
|
||||
transpilesCorrectly("Generates module output", `var x = 0;`, {
|
||||
transpilesCorrectly("Generates module output", `var x = 0; export {};`, {
|
||||
options: { compilerOptions: { module: ts.ModuleKind.AMD } }
|
||||
});
|
||||
|
||||
@@ -139,7 +139,7 @@ var x = 0;`, {
|
||||
testVerbatimModuleSyntax: true
|
||||
});
|
||||
|
||||
transpilesCorrectly("Sets module name", "var x = 1;", {
|
||||
transpilesCorrectly("Sets module name", "var x = 1; export {};", {
|
||||
options: { compilerOptions: { module: ts.ModuleKind.System, newLine: ts.NewLineKind.LineFeed }, moduleName: "NamedModule" }
|
||||
});
|
||||
|
||||
|
||||
@@ -304,6 +304,7 @@ describe("unittests:: TransformAPI", () => {
|
||||
target: ts.ScriptTarget.ES5,
|
||||
module: ts.ModuleKind.System,
|
||||
newLine: ts.NewLineKind.CarriageReturnLineFeed,
|
||||
moduleDetection: ts.ModuleDetectionKind.Force,
|
||||
}
|
||||
}).outputText;
|
||||
|
||||
|
||||
@@ -69,14 +69,40 @@ var C = /** @class */ (function () {
|
||||
return C;
|
||||
}());
|
||||
//// [script.js]
|
||||
var tslib_1 = require("tslib");
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
var A = /** @class */ (function () {
|
||||
function A() {
|
||||
}
|
||||
return A;
|
||||
}());
|
||||
var B = /** @class */ (function (_super) {
|
||||
tslib_1.__extends(B, _super);
|
||||
__extends(B, _super);
|
||||
function B() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
@@ -87,13 +113,13 @@ var C = /** @class */ (function () {
|
||||
}
|
||||
C.prototype.method = function (x) {
|
||||
};
|
||||
tslib_1.__decorate([
|
||||
tslib_1.__param(0, dec),
|
||||
tslib_1.__metadata("design:type", Function),
|
||||
tslib_1.__metadata("design:paramtypes", [Number]),
|
||||
tslib_1.__metadata("design:returntype", void 0)
|
||||
__decorate([
|
||||
__param(0, dec),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Number]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], C.prototype, "method", null);
|
||||
C = tslib_1.__decorate([
|
||||
C = __decorate([
|
||||
dec
|
||||
], C);
|
||||
return C;
|
||||
|
||||
@@ -4,7 +4,4 @@ run(1);
|
||||
|
||||
|
||||
//// [isolatedModulesPlainFile-AMD.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
run(1);
|
||||
});
|
||||
run(1);
|
||||
|
||||
@@ -4,12 +4,4 @@ run(1);
|
||||
|
||||
|
||||
//// [isolatedModulesPlainFile-System.js]
|
||||
System.register([], function (exports_1, context_1) {
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
run(1);
|
||||
}
|
||||
};
|
||||
});
|
||||
run(1);
|
||||
|
||||
@@ -4,15 +4,4 @@ run(1);
|
||||
|
||||
|
||||
//// [isolatedModulesPlainFile-UMD.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";
|
||||
run(1);
|
||||
});
|
||||
run(1);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
System.register(["./comp1"], function (exports_1, context_1) {
|
||||
"use strict";
|
||||
var i0;
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
return {
|
||||
|
||||
@@ -3,4 +3,4 @@ error TS5107: Option 'target=ES3' is deprecated and will stop functioning in Typ
|
||||
|
||||
!!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
|
||||
==== file.ts (0 errors) ====
|
||||
var x = 0;
|
||||
var x = 0; export {};
|
||||
@@ -1,5 +1,6 @@
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
var x = 0;
|
||||
});
|
||||
//# sourceMappingURL=file.js.map
|
||||
@@ -3,4 +3,4 @@ error TS5107: Option 'target=ES3' is deprecated and will stop functioning in Typ
|
||||
|
||||
!!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
|
||||
==== file.ts (0 errors) ====
|
||||
var x = 0;
|
||||
var x = 0; export {};
|
||||
@@ -1,5 +1,6 @@
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
var x = 0;
|
||||
});
|
||||
//# sourceMappingURL=file.js.map
|
||||
@@ -3,4 +3,4 @@ error TS5107: Option 'target=ES3' is deprecated and will stop functioning in Typ
|
||||
|
||||
!!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
|
||||
==== file.ts (0 errors) ====
|
||||
var x = 1;
|
||||
var x = 1; export {};
|
||||
@@ -1,4 +1,5 @@
|
||||
System.register("NamedModule", [], function (exports_1, context_1) {
|
||||
"use strict";
|
||||
var x;
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
return {
|
||||
|
||||
@@ -3,4 +3,4 @@ error TS5107: Option 'target=ES3' is deprecated and will stop functioning in Typ
|
||||
|
||||
!!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error.
|
||||
==== file.ts (0 errors) ====
|
||||
var x = 1;
|
||||
var x = 1; export {};
|
||||
@@ -1,4 +1,5 @@
|
||||
System.register("NamedModule", [], function (exports_1, context_1) {
|
||||
"use strict";
|
||||
var x;
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user