@@ -113,11 +113,154 @@ export const Fragment: unique symbol;
113
113
path : `${ projectRoot } /tsconfig.json` ,
114
114
content : JSON . stringify ( {
115
115
compilerOptions : { jsx : "react-jsx" , jsxImportSource : "react" , forceConsistentCasingInFileNames : true } ,
116
- files : [ "node_modules/react/Jsx-runtime /index.d.ts" , "index.tsx" ]
116
+ files : [ "node_modules/react/jsx-Runtime /index.d.ts" , "index.tsx" ] // NB: casing does not match disk
117
117
} )
118
118
}
119
119
] , { currentDirectory : projectRoot } ) ,
120
120
changes : emptyArray ,
121
121
} ) ;
122
+
123
+ function verifyWindowsStyleRoot ( subScenario : string , windowsStyleRoot : string , projectRootRelative : string ) {
124
+ verifyTscWatch ( {
125
+ scenario : "forceConsistentCasingInFileNames" ,
126
+ subScenario,
127
+ commandLineArgs : [ "--w" , "--p" , `${ windowsStyleRoot } /${ projectRootRelative } ` , "--explainFiles" ] ,
128
+ sys : ( ) => {
129
+ const moduleA : File = {
130
+ path : `${ windowsStyleRoot } /${ projectRootRelative } /a.ts` ,
131
+ content : `
132
+ export const a = 1;
133
+ export const b = 2;
134
+ `
135
+ } ;
136
+ const moduleB : File = {
137
+ path : `${ windowsStyleRoot } /${ projectRootRelative } /b.ts` ,
138
+ content : `
139
+ import { a } from "${ windowsStyleRoot . toLocaleUpperCase ( ) } /${ projectRootRelative } /a"
140
+ import { b } from "${ windowsStyleRoot . toLocaleLowerCase ( ) } /${ projectRootRelative } /a"
141
+
142
+ a;b;
143
+ `
144
+ } ;
145
+ const tsconfig : File = {
146
+ path : `${ windowsStyleRoot } /${ projectRootRelative } /tsconfig.json` ,
147
+ content : JSON . stringify ( { compilerOptions : { forceConsistentCasingInFileNames : true } } )
148
+ } ;
149
+ return createWatchedSystem ( [ moduleA , moduleB , libFile , tsconfig ] , { windowsStyleRoot, useCaseSensitiveFileNames : false } ) ;
150
+ } ,
151
+ changes : [
152
+ {
153
+ caption : "Prepend a line to moduleA" ,
154
+ change : sys => sys . prependFile ( `${ windowsStyleRoot } /${ projectRootRelative } /a.ts` , `// some comment
155
+ ` ) ,
156
+ timeouts : runQueuedTimeoutCallbacks ,
157
+ }
158
+ ] ,
159
+ } ) ;
160
+ }
161
+
162
+ verifyWindowsStyleRoot ( "when Windows-style drive root is lowercase" , "c:/" , "project" ) ;
163
+ verifyWindowsStyleRoot ( "when Windows-style drive root is uppercase" , "C:/" , "project" ) ;
164
+
165
+ function verifyFileSymlink ( subScenario : string , diskPath : string , targetPath : string , importedPath : string ) {
166
+ verifyTscWatch ( {
167
+ scenario : "forceConsistentCasingInFileNames" ,
168
+ subScenario,
169
+ commandLineArgs : [ "--w" , "--p" , "." , "--explainFiles" ] ,
170
+ sys : ( ) => {
171
+ const moduleA : File = {
172
+
173
+ path : diskPath ,
174
+ content : `
175
+ export const a = 1;
176
+ export const b = 2;
177
+ `
178
+ } ;
179
+ const symlinkA : SymLink = {
180
+ path : `${ projectRoot } /link.ts` ,
181
+ symLink : targetPath ,
182
+ } ;
183
+ const moduleB : File = {
184
+ path : `${ projectRoot } /b.ts` ,
185
+ content : `
186
+ import { a } from "${ importedPath } ";
187
+ import { b } from "./link";
188
+
189
+ a;b;
190
+ `
191
+ } ;
192
+ const tsconfig : File = {
193
+ path : `${ projectRoot } /tsconfig.json` ,
194
+ content : JSON . stringify ( { compilerOptions : { forceConsistentCasingInFileNames : true } } )
195
+ } ;
196
+ return createWatchedSystem ( [ moduleA , symlinkA , moduleB , libFile , tsconfig ] , { currentDirectory : projectRoot } ) ;
197
+ } ,
198
+ changes : [
199
+ {
200
+ caption : "Prepend a line to moduleA" ,
201
+ change : sys => sys . prependFile ( diskPath , `// some comment
202
+ ` ) ,
203
+ timeouts : runQueuedTimeoutCallbacks ,
204
+ }
205
+ ] ,
206
+ } ) ;
207
+ }
208
+
209
+ verifyFileSymlink ( "when both file symlink target and import match disk" , `${ projectRoot } /XY.ts` , `${ projectRoot } /XY.ts` , `./XY` ) ;
210
+ verifyFileSymlink ( "when file symlink target matches disk but import does not" , `${ projectRoot } /XY.ts` , `${ projectRoot } /Xy.ts` , `./XY` ) ;
211
+ verifyFileSymlink ( "when import matches disk but file symlink target does not" , `${ projectRoot } /XY.ts` , `${ projectRoot } /XY.ts` , `./Xy` ) ;
212
+ verifyFileSymlink ( "when import and file symlink target agree but do not match disk" , `${ projectRoot } /XY.ts` , `${ projectRoot } /Xy.ts` , `./Xy` ) ;
213
+ verifyFileSymlink ( "when import, file symlink target, and disk are all different" , `${ projectRoot } /XY.ts` , `${ projectRoot } /Xy.ts` , `./yX` ) ;
214
+
215
+ function verifyDirSymlink ( subScenario : string , diskPath : string , targetPath : string , importedPath : string ) {
216
+ verifyTscWatch ( {
217
+ scenario : "forceConsistentCasingInFileNames" ,
218
+ subScenario,
219
+ commandLineArgs : [ "--w" , "--p" , "." , "--explainFiles" ] ,
220
+ sys : ( ) => {
221
+ const moduleA : File = {
222
+
223
+ path : `${ diskPath } /a.ts` ,
224
+ content : `
225
+ export const a = 1;
226
+ export const b = 2;
227
+ `
228
+ } ;
229
+ const symlinkA : SymLink = {
230
+ path : `${ projectRoot } /link` ,
231
+ symLink : targetPath ,
232
+ } ;
233
+ const moduleB : File = {
234
+ path : `${ projectRoot } /b.ts` ,
235
+ content : `
236
+ import { a } from "${ importedPath } /a";
237
+ import { b } from "./link/a";
238
+
239
+ a;b;
240
+ `
241
+ } ;
242
+ const tsconfig : File = {
243
+ path : `${ projectRoot } /tsconfig.json` ,
244
+ // Use outFile because otherwise the real and linked files will have the same output path
245
+ content : JSON . stringify ( { compilerOptions : { forceConsistentCasingInFileNames : true , outFile : "out.js" , module : "system" } } )
246
+ } ;
247
+ return createWatchedSystem ( [ moduleA , symlinkA , moduleB , libFile , tsconfig ] , { currentDirectory : projectRoot } ) ;
248
+ } ,
249
+ changes : [
250
+ {
251
+ caption : "Prepend a line to moduleA" ,
252
+ change : sys => sys . prependFile ( `${ diskPath } /a.ts` , `// some comment
253
+ ` ) ,
254
+ timeouts : runQueuedTimeoutCallbacks ,
255
+ }
256
+ ] ,
257
+ } ) ;
258
+ }
259
+
260
+ verifyDirSymlink ( "when both directory symlink target and import match disk" , `${ projectRoot } /XY` , `${ projectRoot } /XY` , `./XY` ) ;
261
+ verifyDirSymlink ( "when directory symlink target matches disk but import does not" , `${ projectRoot } /XY` , `${ projectRoot } /Xy` , `./XY` ) ;
262
+ verifyDirSymlink ( "when import matches disk but directory symlink target does not" , `${ projectRoot } /XY` , `${ projectRoot } /XY` , `./Xy` ) ;
263
+ verifyDirSymlink ( "when import and directory symlink target agree but do not match disk" , `${ projectRoot } /XY` , `${ projectRoot } /Xy` , `./Xy` ) ;
264
+ verifyDirSymlink ( "when import, directory symlink target, and disk are all different" , `${ projectRoot } /XY` , `${ projectRoot } /Xy` , `./yX` ) ;
122
265
} ) ;
123
266
}
0 commit comments