Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #31165 from Microsoft/targetAffectsEmit
Browse files Browse the repository at this point in the history
Target affects emit hence mark the option so that all files are reemitted when target changes
  • Loading branch information
sheetalkamat committed Apr 29, 2019
2 parents 7423c69 + fb21e70 commit 7e135e7
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/compiler/commandLineParser.ts
Expand Up @@ -218,6 +218,7 @@ namespace ts {
}),
affectsSourceFile: true,
affectsModuleResolution: true,
affectsEmit: true,
paramType: Diagnostics.VERSION,
showInSimplifiedHelpView: true,
category: Diagnostics.Basic_Options,
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/unittests/tsbuild/helpers.ts
Expand Up @@ -62,7 +62,7 @@ namespace ts {
}
}

const libContent = `${TestFSWithWatch.libFile.content}
export const libContent = `${TestFSWithWatch.libFile.content}
interface ReadonlyArray<T> {}
declare const console: { log(msg: any): void; };`;

Expand Down
54 changes: 51 additions & 3 deletions src/testRunner/unittests/tsbuild/sample.ts
Expand Up @@ -279,7 +279,6 @@ namespace ts {
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/logic/tsconfig.json", "src/logic/index.ts", "src/logic/index.js"],
[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"],
[Diagnostics.Updating_unchanged_output_timestamps_of_project_0, "/src/tests/tsconfig.json"]
);
});

Expand Down Expand Up @@ -309,8 +308,7 @@ namespace ts {
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/core/tsconfig.json", "src/core/anotherModule.ts", "src/core/anotherModule.js"],
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/logic/tsconfig.json", "src/logic/index.ts", "src/logic/index.js"],
[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.base.json"],
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"],
[Diagnostics.Updating_unchanged_output_timestamps_of_project_0, "/src/tests/tsconfig.json"]
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"]
);
});
});
Expand Down Expand Up @@ -761,6 +759,56 @@ class someClass { }`),
baselineOnly: true,
verifyDiagnostics: true
});

verifyTsbuildOutput({
scenario: "when target option changes",
projFs: () => projFs,
time,
tick,
proj: "sample1",
rootNames: ["/src/core"],
expectedMapFileNames: emptyArray,
lastProjectOutputJs: "/src/core/index.js",
initialBuild: {
modifyFs: fs => {
fs.writeFileSync("/lib/lib.esnext.full.d.ts", `/// <reference no-default-lib="true"/>
/// <reference lib="esnext" />`);
fs.writeFileSync("/lib/lib.esnext.d.ts", libContent);
fs.writeFileSync("/lib/lib.d.ts", `/// <reference no-default-lib="true"/>
/// <reference lib="esnext" />`);
fs.writeFileSync("/src/core/tsconfig.json", `{
"compilerOptions": {
"incremental": true,
"listFiles": true,
"listEmittedFiles": true,
"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"],
[Diagnostics.Building_project_0, "/src/core/tsconfig.json"],
]
},
incrementalDtsChangedBuild: {
modifyFs: fs => replaceText(fs, "/src/core/tsconfig.json", "esnext", "es5"),
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/anotherModule.d.ts",
"/src/core/index.js",
"/src/core/index.d.ts",
"/src/core/tsconfig.tsbuildinfo",
],
baselineOnly: true,
verifyDiagnostics: true
});
});
});
}
@@ -0,0 +1,71 @@
//// [/src/core/anotherModule.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.World = "hello";


//// [/src/core/index.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: 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,
"listFiles": true,
"listEmittedFiles": true,
"target": "es5",
}
}

//// [/src/core/tsconfig.tsbuildinfo]
{
"program": {
"fileInfos": {
"/lib/lib.d.ts": {
"version": "8926001564",
"signature": "8926001564"
},
"/lib/lib.esnext.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
},
"/src/core/anothermodule.ts": {
"version": "-2676574883",
"signature": "-8396256275"
},
"/src/core/index.ts": {
"version": "-18749805970",
"signature": "1874987148"
},
"/src/core/some_decl.d.ts": {
"version": "-9253692965",
"signature": "-9253692965"
}
},
"options": {
"incremental": true,
"listFiles": true,
"listEmittedFiles": true,
"target": 1,
"configFilePath": "/src/core/tsconfig.json"
},
"referencedMap": {},
"exportedModulesMap": {},
"semanticDiagnosticsPerFile": [
"/lib/lib.d.ts",
"/lib/lib.esnext.d.ts",
"/src/core/anothermodule.ts",
"/src/core/index.ts",
"/src/core/some_decl.d.ts"
]
},
"version": "FakeTSVersion"
}

@@ -0,0 +1,88 @@
//// [/lib/lib.d.ts]
/// <reference no-default-lib="true"/>
/// <reference lib="esnext" />

//// [/lib/lib.esnext.d.ts]
/// <reference no-default-lib="true"/>
interface Boolean {}
interface Function {}
interface CallableFunction {}
interface NewableFunction {}
interface IArguments {}
interface Number { toExponential: any; }
interface Object {}
interface RegExp {}
interface String { charAt: any; }
interface Array<T> {}
interface ReadonlyArray<T> {}
declare const console: { log(msg: any): void; };

//// [/lib/lib.esnext.full.d.ts]
/// <reference no-default-lib="true"/>
/// <reference lib="esnext" />

//// [/src/core/anotherModule.js]
export const World = "hello";


//// [/src/core/index.js]
export const someString = "HELLO WORLD";
export function leftPad(s, n) { return s + n; }
export function multiply(a, b) { return a * b; }


//// [/src/core/tsconfig.json]
{
"compilerOptions": {
"incremental": true,
"listFiles": true,
"listEmittedFiles": true,
"target": "esnext",
}
}

//// [/src/core/tsconfig.tsbuildinfo]
{
"program": {
"fileInfos": {
"/lib/lib.esnext.d.ts": {
"version": "-15964756381",
"signature": "-15964756381"
},
"/lib/lib.esnext.full.d.ts": {
"version": "8926001564",
"signature": "8926001564"
},
"/src/core/anothermodule.ts": {
"version": "-2676574883",
"signature": "-8396256275"
},
"/src/core/index.ts": {
"version": "-18749805970",
"signature": "1874987148"
},
"/src/core/some_decl.d.ts": {
"version": "-9253692965",
"signature": "-9253692965"
}
},
"options": {
"incremental": true,
"listFiles": true,
"listEmittedFiles": true,
"target": 8,
"configFilePath": "/src/core/tsconfig.json"
},
"referencedMap": {},
"exportedModulesMap": {},
"semanticDiagnosticsPerFile": [
"/lib/lib.esnext.d.ts",
"/lib/lib.esnext.full.d.ts",
"/src/core/anothermodule.ts",
"/src/core/index.ts",
"/src/core/some_decl.d.ts"
]
},
"version": "FakeTSVersion"
}

0 comments on commit 7e135e7

Please sign in to comment.