Skip to content

Commit 342f4c0

Browse files
ajafffsheetalkamat
authored andcommitted
forceConsistentCasingInFileNames affects module resolution (#36334)
1 parent 8976ac9 commit 342f4c0

File tree

3 files changed

+152
-0
lines changed

3 files changed

+152
-0
lines changed

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,7 @@ namespace ts {
951951
{
952952
name: "forceConsistentCasingInFileNames",
953953
type: "boolean",
954+
affectsModuleResolution: true,
954955
category: Diagnostics.Advanced_Options,
955956
description: Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file
956957
},

src/testRunner/unittests/tscWatch/programUpdates.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,35 @@ export function f(p: C) { return p; }`
12281228
]
12291229
});
12301230

1231+
1232+
verifyTscWatch({
1233+
scenario,
1234+
subScenario: "updates errors when forceConsistentCasingInFileNames changes",
1235+
commandLineArgs: ["-w"],
1236+
sys: () => {
1237+
const aFile: File = {
1238+
path: `/a.ts`,
1239+
content: `export class C {}`
1240+
};
1241+
const bFile: File = {
1242+
path: `/b.ts`,
1243+
content: `import {C} from './a'; import * as A from './A';`
1244+
};
1245+
const config: File = {
1246+
path: `/tsconfig.json`,
1247+
content: JSON.stringify({ compilerOptions: {} })
1248+
};
1249+
return createWatchedSystem([aFile, bFile, config, libFile], { useCaseSensitiveFileNames: false });
1250+
},
1251+
changes: [
1252+
sys => {
1253+
sys.writeFile(`/tsconfig.json`, JSON.stringify({ compilerOptions: { forceConsistentCasingInFileNames: true } }));
1254+
sys.runQueuedTimeoutCallbacks();
1255+
return "Enable forceConsistentCasingInFileNames";
1256+
},
1257+
]
1258+
});
1259+
12311260
verifyTscWatch({
12321261
scenario,
12331262
subScenario: "updates moduleResolution when resolveJsonModule changes",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/a/lib/tsc.js -w
2+
//// [/a.ts]
3+
export class C {}
4+
5+
//// [/b.ts]
6+
import {C} from './a'; import * as A from './A';
7+
8+
//// [/tsconfig.json]
9+
{"compilerOptions":{}}
10+
11+
//// [/a/lib/lib.d.ts]
12+
/// <reference no-default-lib="true"/>
13+
interface Boolean {}
14+
interface Function {}
15+
interface CallableFunction {}
16+
interface NewableFunction {}
17+
interface IArguments {}
18+
interface Number { toExponential: any; }
19+
interface Object {}
20+
interface RegExp {}
21+
interface String { charAt: any; }
22+
interface Array<T> { length: number; [n: number]: T; }
23+
24+
//// [/a.js]
25+
"use strict";
26+
exports.__esModule = true;
27+
var C = /** @class */ (function () {
28+
function C() {
29+
}
30+
return C;
31+
}());
32+
exports.C = C;
33+
34+
35+
//// [/b.js]
36+
"use strict";
37+
exports.__esModule = true;
38+
39+
40+
41+
Output::
42+
>> Screen clear
43+
12:00:15 AM - Starting compilation in watch mode...
44+
45+
46+
47+
12:00:20 AM - Found 0 errors. Watching for file changes.
48+
49+
50+
Program root files: ["/a.ts","/b.ts","/a/lib/lib.d.ts"]
51+
Program options: {"watch":true,"configFilePath":"/tsconfig.json"}
52+
Program files::
53+
/a.ts
54+
/b.ts
55+
/a/lib/lib.d.ts
56+
57+
Semantic diagnostics in builder refreshed for::
58+
/a.ts
59+
/b.ts
60+
/a/lib/lib.d.ts
61+
62+
WatchedFiles::
63+
/tsconfig.json:
64+
{"pollingInterval":250}
65+
/a.ts:
66+
{"pollingInterval":250}
67+
/b.ts:
68+
{"pollingInterval":250}
69+
/a/lib/lib.d.ts:
70+
{"pollingInterval":250}
71+
72+
FsWatches::
73+
74+
FsWatchesRecursive::
75+
/:
76+
{"fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
77+
78+
exitCode:: ExitStatus.undefined
79+
80+
Change:: Enable forceConsistentCasingInFileNames
81+
82+
//// [/tsconfig.json]
83+
{"compilerOptions":{"forceConsistentCasingInFileNames":true}}
84+
85+
86+
Output::
87+
>> Screen clear
88+
12:00:24 AM - File change detected. Starting incremental compilation...
89+
90+
91+
b.ts(1,43): error TS1149: File name '/A.ts' differs from already included file name '/a.ts' only in casing.
92+
93+
94+
12:00:25 AM - Found 1 error. Watching for file changes.
95+
96+
97+
Program root files: ["/a.ts","/b.ts","/a/lib/lib.d.ts"]
98+
Program options: {"forceConsistentCasingInFileNames":true,"watch":true,"configFilePath":"/tsconfig.json"}
99+
Program files::
100+
/a.ts
101+
/b.ts
102+
/a/lib/lib.d.ts
103+
104+
Semantic diagnostics in builder refreshed for::
105+
106+
WatchedFiles::
107+
/tsconfig.json:
108+
{"pollingInterval":250}
109+
/a.ts:
110+
{"pollingInterval":250}
111+
/b.ts:
112+
{"pollingInterval":250}
113+
/a/lib/lib.d.ts:
114+
{"pollingInterval":250}
115+
116+
FsWatches::
117+
118+
FsWatchesRecursive::
119+
/:
120+
{"fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
121+
122+
exitCode:: ExitStatus.undefined

0 commit comments

Comments
 (0)