Skip to content

Commit cfa55f1

Browse files
authored
Fixes the tests that got disabled when generating config set es2016 expecting to find libFile and remove incorrect affects flag from listFilesOnly (microsoft#51243)
* Fix the existing test * Remove affectsEmit from listFilesOnly
1 parent 18f559f commit cfa55f1

File tree

11 files changed

+282
-1080
lines changed

11 files changed

+282
-1080
lines changed

src/compiler/commandLineParser.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,6 @@ namespace ts {
436436
name: "listFilesOnly",
437437
type: "boolean",
438438
category: Diagnostics.Command_line_Options,
439-
affectsSemanticDiagnostics: true,
440-
affectsEmit: true,
441-
affectsMultiFileEmitBuildInfo: true,
442439
isCommandLineOnly: true,
443440
description: Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing,
444441
defaultValueDescription: false,
@@ -2411,7 +2408,8 @@ namespace ts {
24112408
return config;
24122409
}
24132410

2414-
function optionMapToObject(optionMap: ESMap<string, CompilerOptionsValue>): object {
2411+
/*@internal*/
2412+
export function optionMapToObject(optionMap: ESMap<string, CompilerOptionsValue>): object {
24152413
return {
24162414
...arrayFrom(optionMap.entries()).reduce((prev, cur) => ({ ...prev, [cur[0]]: cur[1] }), {}),
24172415
};
@@ -2464,7 +2462,8 @@ namespace ts {
24642462
});
24652463
}
24662464

2467-
function serializeCompilerOptions(
2465+
/* @internal */
2466+
export function serializeCompilerOptions(
24682467
options: CompilerOptions,
24692468
pathOptions?: { configFilePath: string, useCaseSensitiveFileNames: boolean }
24702469
): ESMap<string, CompilerOptionsValue> {

src/testRunner/unittests/tsc/helpers.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ namespace ts {
66
storeFilesChangingSignatureDuringEmit?: boolean;
77
};
88

9+
export function compilerOptionsToConfigJson(options: CompilerOptions) {
10+
return optionMapToObject(serializeCompilerOptions(options));
11+
}
12+
913
export const noChangeRun: TestTscEdit = {
1014
subScenario: "no-change-run",
1115
modifyFs: noop

src/testRunner/unittests/tsc/listFilesOnly.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,26 @@ namespace ts {
1919
}),
2020
commandLineArgs: ["/src/test.ts", "--listFilesOnly"]
2121
});
22+
23+
verifyTscWithEdits({
24+
scenario: "listFilesOnly",
25+
subScenario: "combined with incremental",
26+
fs: () => loadProjectFromFiles({
27+
"/src/test.ts": `export const x = 1;`,
28+
"/src/tsconfig.json": "{}"
29+
}),
30+
commandLineArgs: ["-p", "/src", "--incremental", "--listFilesOnly"],
31+
edits: [
32+
{
33+
...noChangeRun,
34+
commandLineArgs: ["-p", "/src", "--incremental"],
35+
},
36+
noChangeRun,
37+
{
38+
...noChangeRun,
39+
commandLineArgs: ["-p", "/src", "--incremental"],
40+
}
41+
]
42+
});
2243
});
2344
}

src/testRunner/unittests/tscWatch/programUpdates.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,9 @@ declare const eval: any`
11641164
};
11651165
const tsconfig: File = {
11661166
path: `${projectRoot}/tsconfig.json`,
1167-
content: generateTSConfig(options, emptyArray, "\n")
1167+
content: JSON.stringify({
1168+
compilerOptions: compilerOptionsToConfigJson(options)
1169+
})
11681170
};
11691171
return createWatchedSystem([file1, file2, libFile, tsconfig], { currentDirectory: projectRoot });
11701172
},
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
Input::
2+
//// [/lib/lib.d.ts]
3+
/// <reference no-default-lib="true"/>
4+
interface Boolean {}
5+
interface Function {}
6+
interface CallableFunction {}
7+
interface NewableFunction {}
8+
interface IArguments {}
9+
interface Number { toExponential: any; }
10+
interface Object {}
11+
interface RegExp {}
12+
interface String { charAt: any; }
13+
interface Array<T> { length: number; [n: number]: T; }
14+
interface ReadonlyArray<T> {}
15+
declare const console: { log(msg: any): void; };
16+
17+
//// [/src/test.ts]
18+
export const x = 1;
19+
20+
//// [/src/tsconfig.json]
21+
{}
22+
23+
24+
25+
Output::
26+
/lib/tsc -p /src --incremental --listFilesOnly
27+
/lib/lib.d.ts
28+
/src/test.ts
29+
exitCode:: ExitStatus.Success
30+
31+
32+
33+
34+
Change:: no-change-run
35+
Input::
36+
37+
38+
Output::
39+
/lib/tsc -p /src --incremental
40+
exitCode:: ExitStatus.Success
41+
42+
43+
//// [/src/test.js]
44+
"use strict";
45+
exports.__esModule = true;
46+
exports.x = void 0;
47+
exports.x = 1;
48+
49+
50+
//// [/src/tsconfig.tsbuildinfo]
51+
{"program":{"fileNames":["../lib/lib.d.ts","./test.ts"],"fileInfos":[{"version":"3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-12038591281-export const x = 1;"],"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2]},"version":"FakeTSVersion"}
52+
53+
//// [/src/tsconfig.tsbuildinfo.readable.baseline.txt]
54+
{
55+
"program": {
56+
"fileNames": [
57+
"../lib/lib.d.ts",
58+
"./test.ts"
59+
],
60+
"fileInfos": {
61+
"../lib/lib.d.ts": {
62+
"version": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
63+
"signature": "3858781397-/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }\ninterface ReadonlyArray<T> {}\ndeclare const console: { log(msg: any): void; };",
64+
"affectsGlobalScope": true
65+
},
66+
"./test.ts": {
67+
"version": "-12038591281-export const x = 1;",
68+
"signature": "-12038591281-export const x = 1;"
69+
}
70+
},
71+
"referencedMap": {},
72+
"exportedModulesMap": {},
73+
"semanticDiagnosticsPerFile": [
74+
"../lib/lib.d.ts",
75+
"./test.ts"
76+
]
77+
},
78+
"version": "FakeTSVersion",
79+
"size": 689
80+
}
81+
82+
83+
84+
Change:: no-change-run
85+
Input::
86+
87+
88+
Output::
89+
/lib/tsc -p /src --incremental --listFilesOnly
90+
/lib/lib.d.ts
91+
/src/test.ts
92+
exitCode:: ExitStatus.Success
93+
94+
95+
96+
97+
Change:: no-change-run
98+
Input::
99+
100+
101+
Output::
102+
/lib/tsc -p /src --incremental
103+
exitCode:: ExitStatus.Success
104+
105+

0 commit comments

Comments
 (0)