mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 20:37:46 -05:00
Add tests for module and esModuleInterop affectsEmit change
This commit is contained in:
@@ -906,7 +906,7 @@ class someClass { }`),
|
||||
"target": "esnext",
|
||||
}
|
||||
}`);
|
||||
},
|
||||
},
|
||||
expectedDiagnostics: [
|
||||
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json"),
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/core/tsconfig.json", "src/core/anotherModule.js"],
|
||||
@@ -931,6 +931,88 @@ class someClass { }`),
|
||||
baselineOnly: true,
|
||||
verifyDiagnostics: true
|
||||
});
|
||||
|
||||
verifyTsbuildOutput({
|
||||
scenario: "when module option changes",
|
||||
projFs: () => projFs,
|
||||
time,
|
||||
tick,
|
||||
proj: "sample1",
|
||||
rootNames: ["/src/core"],
|
||||
expectedMapFileNames: emptyArray,
|
||||
lastProjectOutputJs: "/src/core/index.js",
|
||||
initialBuild: {
|
||||
modifyFs: fs => fs.writeFileSync("/src/core/tsconfig.json", `{
|
||||
"compilerOptions": {
|
||||
"incremental": true,
|
||||
"module": "commonjs"
|
||||
}
|
||||
}`),
|
||||
expectedDiagnostics: [
|
||||
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json"),
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/core/tsconfig.json", "src/core/anotherModule.js"],
|
||||
[Diagnostics.Building_project_0, "/src/core/tsconfig.json"],
|
||||
]
|
||||
},
|
||||
incrementalDtsChangedBuild: {
|
||||
modifyFs: fs => replaceText(fs, "/src/core/tsconfig.json", `"module": "commonjs"`, `"module": "amd"`),
|
||||
expectedDiagnostics: [
|
||||
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json"),
|
||||
[Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/core/tsconfig.json", "src/core/anotherModule.js", "src/core/tsconfig.json"],
|
||||
[Diagnostics.Building_project_0, "/src/core/tsconfig.json"]
|
||||
]
|
||||
},
|
||||
outputFiles: [
|
||||
"/src/core/anotherModule.js",
|
||||
"/src/core/index.js",
|
||||
"/src/core/tsconfig.tsbuildinfo",
|
||||
],
|
||||
baselineOnly: true,
|
||||
verifyDiagnostics: true
|
||||
});
|
||||
|
||||
verifyTsbuildOutput({
|
||||
scenario: "when esModuleInterop option changes",
|
||||
projFs: () => projFs,
|
||||
time,
|
||||
tick,
|
||||
proj: "sample1",
|
||||
rootNames: ["/src/tests"],
|
||||
expectedMapFileNames: emptyArray,
|
||||
lastProjectOutputJs: "/src/tests/index.js",
|
||||
initialBuild: {
|
||||
modifyFs: fs => fs.writeFileSync("/src/tests/tsconfig.json", `{
|
||||
"compilerOptions": {
|
||||
"incremental": true,
|
||||
"module": "commonjs",
|
||||
"esModuleInterop": false
|
||||
}
|
||||
}`),
|
||||
expectedDiagnostics: [
|
||||
getExpectedDiagnosticForProjectsInBuild("src/tests/tsconfig.json"),
|
||||
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/tests/tsconfig.json", "src/tests/index.js"],
|
||||
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"],
|
||||
]
|
||||
},
|
||||
incrementalDtsChangedBuild: {
|
||||
modifyFs: fs => replaceText(fs, "/src/tests/tsconfig.json", `"esModuleInterop": false`, `"esModuleInterop": true`),
|
||||
expectedDiagnostics: [
|
||||
getExpectedDiagnosticForProjectsInBuild("src/tests/tsconfig.json"),
|
||||
[Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/tests/tsconfig.json", "src/tests/index.js", "src/tests/tsconfig.json"],
|
||||
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"]
|
||||
]
|
||||
},
|
||||
outputFiles: [
|
||||
"/src/core/anotherModule.js",
|
||||
"/src/core/index.js",
|
||||
"/src/logic/index.js",
|
||||
"/src/tests/index.js",
|
||||
"/src/tests/tsconfig.json",
|
||||
"/src/tests/tsconfig.tsbuildinfo"
|
||||
],
|
||||
baselineOnly: true,
|
||||
verifyDiagnostics: true
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
//// [/src/logic/index.js]
|
||||
"use strict";
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
exports.__esModule = true;
|
||||
var c = __importStar(require("../core/index"));
|
||||
function getSecondsInDay() {
|
||||
return c.multiply(10, 15);
|
||||
}
|
||||
exports.getSecondsInDay = getSecondsInDay;
|
||||
var mod = __importStar(require("../core/anotherModule"));
|
||||
exports.m = mod;
|
||||
|
||||
|
||||
//// [/src/tests/index.js]
|
||||
"use strict";
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
exports.__esModule = true;
|
||||
var c = __importStar(require("../core/index"));
|
||||
var logic = __importStar(require("../logic/index"));
|
||||
c.leftPad("", 10);
|
||||
logic.getSecondsInDay();
|
||||
var mod = __importStar(require("../core/anotherModule"));
|
||||
exports.m = mod;
|
||||
|
||||
|
||||
//// [/src/tests/tsconfig.json]
|
||||
{
|
||||
"compilerOptions": {
|
||||
"incremental": true,
|
||||
"module": "commonjs",
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/tests/tsconfig.tsbuildinfo]
|
||||
{
|
||||
"program": {
|
||||
"fileInfos": {
|
||||
"../../lib/lib.d.ts": {
|
||||
"version": "-15964756381",
|
||||
"signature": "-15964756381"
|
||||
},
|
||||
"../core/index.ts": {
|
||||
"version": "-18749805970",
|
||||
"signature": "1874987148"
|
||||
},
|
||||
"../core/anothermodule.ts": {
|
||||
"version": "-2676574883",
|
||||
"signature": "-8396256275"
|
||||
},
|
||||
"../logic/index.ts": {
|
||||
"version": "-5786964698",
|
||||
"signature": "-6548680073"
|
||||
},
|
||||
"./index.ts": {
|
||||
"version": "12336236525",
|
||||
"signature": "-9209611"
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"incremental": true,
|
||||
"module": 1,
|
||||
"esModuleInterop": true,
|
||||
"configFilePath": "./tsconfig.json"
|
||||
},
|
||||
"referencedMap": {
|
||||
"../logic/index.ts": [
|
||||
"../core/anothermodule.ts",
|
||||
"../core/index.ts"
|
||||
],
|
||||
"./index.ts": [
|
||||
"../core/anothermodule.ts",
|
||||
"../core/index.ts",
|
||||
"../logic/index.ts"
|
||||
]
|
||||
},
|
||||
"exportedModulesMap": {
|
||||
"../logic/index.ts": [
|
||||
"../core/anothermodule.ts"
|
||||
],
|
||||
"./index.ts": [
|
||||
"../core/anothermodule.ts"
|
||||
]
|
||||
},
|
||||
"semanticDiagnosticsPerFile": [
|
||||
"../../lib/lib.d.ts",
|
||||
"../core/anothermodule.ts",
|
||||
"../core/index.ts",
|
||||
"../logic/index.ts",
|
||||
"./index.ts"
|
||||
]
|
||||
},
|
||||
"version": "FakeTSVersion"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
//// [/src/core/anotherModule.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.World = "hello";
|
||||
});
|
||||
|
||||
|
||||
//// [/src/core/index.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.someString = "HELLO WORLD";
|
||||
function leftPad(s, n) { return s + n; }
|
||||
exports.leftPad = leftPad;
|
||||
function multiply(a, b) { return a * b; }
|
||||
exports.multiply = multiply;
|
||||
});
|
||||
|
||||
|
||||
//// [/src/core/tsconfig.json]
|
||||
{
|
||||
"compilerOptions": {
|
||||
"incremental": true,
|
||||
"module": "amd"
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/core/tsconfig.tsbuildinfo]
|
||||
{
|
||||
"program": {
|
||||
"fileInfos": {
|
||||
"../../lib/lib.d.ts": {
|
||||
"version": "-15964756381",
|
||||
"signature": "-15964756381"
|
||||
},
|
||||
"./anothermodule.ts": {
|
||||
"version": "-2676574883",
|
||||
"signature": "-8396256275"
|
||||
},
|
||||
"./index.ts": {
|
||||
"version": "-18749805970",
|
||||
"signature": "1874987148"
|
||||
},
|
||||
"./some_decl.d.ts": {
|
||||
"version": "-9253692965",
|
||||
"signature": "-9253692965"
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"incremental": true,
|
||||
"module": 2,
|
||||
"configFilePath": "./tsconfig.json"
|
||||
},
|
||||
"referencedMap": {},
|
||||
"exportedModulesMap": {},
|
||||
"semanticDiagnosticsPerFile": [
|
||||
"../../lib/lib.d.ts",
|
||||
"./anothermodule.ts",
|
||||
"./index.ts",
|
||||
"./some_decl.d.ts"
|
||||
]
|
||||
},
|
||||
"version": "FakeTSVersion"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
//// [/src/core/anotherModule.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.World = "hello";
|
||||
|
||||
|
||||
//// [/src/core/index.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.someString = "HELLO WORLD";
|
||||
function leftPad(s, n) { return s + n; }
|
||||
exports.leftPad = leftPad;
|
||||
function multiply(a, b) { return a * b; }
|
||||
exports.multiply = multiply;
|
||||
|
||||
|
||||
//// [/src/logic/index.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
var c = require("../core/index");
|
||||
function getSecondsInDay() {
|
||||
return c.multiply(10, 15);
|
||||
}
|
||||
exports.getSecondsInDay = getSecondsInDay;
|
||||
var mod = require("../core/anotherModule");
|
||||
exports.m = mod;
|
||||
|
||||
|
||||
//// [/src/tests/index.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
var c = require("../core/index");
|
||||
var logic = require("../logic/index");
|
||||
c.leftPad("", 10);
|
||||
logic.getSecondsInDay();
|
||||
var mod = require("../core/anotherModule");
|
||||
exports.m = mod;
|
||||
|
||||
|
||||
//// [/src/tests/tsconfig.json]
|
||||
{
|
||||
"compilerOptions": {
|
||||
"incremental": true,
|
||||
"module": "commonjs",
|
||||
"esModuleInterop": false
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/tests/tsconfig.tsbuildinfo]
|
||||
{
|
||||
"program": {
|
||||
"fileInfos": {
|
||||
"../../lib/lib.d.ts": {
|
||||
"version": "-15964756381",
|
||||
"signature": "-15964756381"
|
||||
},
|
||||
"../core/index.ts": {
|
||||
"version": "-18749805970",
|
||||
"signature": "1874987148"
|
||||
},
|
||||
"../core/anothermodule.ts": {
|
||||
"version": "-2676574883",
|
||||
"signature": "-8396256275"
|
||||
},
|
||||
"../logic/index.ts": {
|
||||
"version": "-5786964698",
|
||||
"signature": "-6548680073"
|
||||
},
|
||||
"./index.ts": {
|
||||
"version": "12336236525",
|
||||
"signature": "-9209611"
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"incremental": true,
|
||||
"module": 1,
|
||||
"esModuleInterop": false,
|
||||
"configFilePath": "./tsconfig.json"
|
||||
},
|
||||
"referencedMap": {
|
||||
"../logic/index.ts": [
|
||||
"../core/anothermodule.ts",
|
||||
"../core/index.ts"
|
||||
],
|
||||
"./index.ts": [
|
||||
"../core/anothermodule.ts",
|
||||
"../core/index.ts",
|
||||
"../logic/index.ts"
|
||||
]
|
||||
},
|
||||
"exportedModulesMap": {
|
||||
"../logic/index.ts": [
|
||||
"../core/anothermodule.ts"
|
||||
],
|
||||
"./index.ts": [
|
||||
"../core/anothermodule.ts"
|
||||
]
|
||||
},
|
||||
"semanticDiagnosticsPerFile": [
|
||||
"../../lib/lib.d.ts",
|
||||
"../core/anothermodule.ts",
|
||||
"../core/index.ts",
|
||||
"../logic/index.ts",
|
||||
"./index.ts"
|
||||
]
|
||||
},
|
||||
"version": "FakeTSVersion"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
//// [/src/core/anotherModule.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.World = "hello";
|
||||
|
||||
|
||||
//// [/src/core/index.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.someString = "HELLO WORLD";
|
||||
function leftPad(s, n) { return s + n; }
|
||||
exports.leftPad = leftPad;
|
||||
function multiply(a, b) { return a * b; }
|
||||
exports.multiply = multiply;
|
||||
|
||||
|
||||
//// [/src/core/tsconfig.json]
|
||||
{
|
||||
"compilerOptions": {
|
||||
"incremental": true,
|
||||
"module": "commonjs"
|
||||
}
|
||||
}
|
||||
|
||||
//// [/src/core/tsconfig.tsbuildinfo]
|
||||
{
|
||||
"program": {
|
||||
"fileInfos": {
|
||||
"../../lib/lib.d.ts": {
|
||||
"version": "-15964756381",
|
||||
"signature": "-15964756381"
|
||||
},
|
||||
"./anothermodule.ts": {
|
||||
"version": "-2676574883",
|
||||
"signature": "-8396256275"
|
||||
},
|
||||
"./index.ts": {
|
||||
"version": "-18749805970",
|
||||
"signature": "1874987148"
|
||||
},
|
||||
"./some_decl.d.ts": {
|
||||
"version": "-9253692965",
|
||||
"signature": "-9253692965"
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"incremental": true,
|
||||
"module": 1,
|
||||
"configFilePath": "./tsconfig.json"
|
||||
},
|
||||
"referencedMap": {},
|
||||
"exportedModulesMap": {},
|
||||
"semanticDiagnosticsPerFile": [
|
||||
"../../lib/lib.d.ts",
|
||||
"./anothermodule.ts",
|
||||
"./index.ts",
|
||||
"./some_decl.d.ts"
|
||||
]
|
||||
},
|
||||
"version": "FakeTSVersion"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user