diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 2f8844897f906..7e65efb01b0a8 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -3120,7 +3120,10 @@ namespace ts { }; } if (isImplicitGlob(spec)) { - return { key: spec, flags: WatchDirectoryFlags.Recursive }; + return { + key: useCaseSensitiveFileNames ? spec : toFileNameLowerCase(spec), + flags: WatchDirectoryFlags.Recursive + }; } return undefined; } diff --git a/src/testRunner/unittests/tscWatch/programUpdates.ts b/src/testRunner/unittests/tscWatch/programUpdates.ts index fb3e008c7d962..988be560f76a5 100644 --- a/src/testRunner/unittests/tscWatch/programUpdates.ts +++ b/src/testRunner/unittests/tscWatch/programUpdates.ts @@ -556,6 +556,30 @@ export class A { ] }); + verifyTscWatch({ + scenario, + subScenario: "can correctly update configured project when set of root files has changed through include", + commandLineArgs: ["-w", "-p", "."], + sys: () => { + const file1 = { + path: `${projectRoot}/Project/file1.ts`, + content: "export const x = 10;" + }; + const configFile = { + path: `${projectRoot}/Project/tsconfig.json`, + content: JSON.stringify({ include: [".", "./**/*.json"] }) + }; + return createWatchedSystem([file1, libFile, configFile], { currentDirectory: `${projectRoot}/Project` }); + }, + changes: [ + { + caption: "Write file2", + change: sys => sys.writeFile(`${projectRoot}/Project/file2.ts`, "export const y = 10;"), + timeouts: checkSingleTimeoutQueueLengthAndRun + } + ] + }); + verifyTscWatch({ scenario, subScenario: "can update configured project when set of root files was not changed", diff --git a/tests/baselines/reference/tscWatch/programUpdates/can-correctly-update-configured-project-when-set-of-root-files-has-changed-through-include.js b/tests/baselines/reference/tscWatch/programUpdates/can-correctly-update-configured-project-when-set-of-root-files-has-changed-through-include.js new file mode 100644 index 0000000000000..5c818908e09f5 --- /dev/null +++ b/tests/baselines/reference/tscWatch/programUpdates/can-correctly-update-configured-project-when-set-of-root-files-has-changed-through-include.js @@ -0,0 +1,124 @@ +Input:: +//// [/user/username/projects/myproject/Project/file1.ts] +export const x = 10; + +//// [/a/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } + +//// [/user/username/projects/myproject/Project/tsconfig.json] +{"include":[".","./**/*.json"]} + + +/a/lib/tsc.js -w -p . +Output:: +>> Screen clear +[12:00:23 AM] Starting compilation in watch mode... + + +[12:00:26 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/Project/file1.ts"] +Program options: {"watch":true,"project":"/user/username/projects/myproject/Project","configFilePath":"/user/username/projects/myproject/Project/tsconfig.json"} +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/Project/file1.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/Project/file1.ts + +WatchedFiles:: +/user/username/projects/myproject/project/tsconfig.json: + {"fileName":"/user/username/projects/myproject/Project/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/project/file1.ts: + {"fileName":"/user/username/projects/myproject/Project/file1.ts","pollingInterval":250} +/a/lib/lib.d.ts: + {"fileName":"/a/lib/lib.d.ts","pollingInterval":250} + +FsWatches:: + +FsWatchesRecursive:: +/user/username/projects/myproject/project/node_modules/@types: + {"directoryName":"/user/username/projects/myproject/Project/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} +/user/username/projects/myproject/node_modules/@types: + {"directoryName":"/user/username/projects/myproject/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} +/user/username/projects/myproject/project: + {"directoryName":"/user/username/projects/myproject/project","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/Project/file1.js] +"use strict"; +exports.__esModule = true; +exports.x = void 0; +exports.x = 10; + + + +Change:: Write file2 + +Input:: +//// [/user/username/projects/myproject/Project/file2.ts] +export const y = 10; + + +Output:: +>> Screen clear +[12:00:29 AM] File change detected. Starting incremental compilation... + + +[12:00:32 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/Project/file1.ts","/user/username/projects/myproject/Project/file2.ts"] +Program options: {"watch":true,"project":"/user/username/projects/myproject/Project","configFilePath":"/user/username/projects/myproject/Project/tsconfig.json"} +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/Project/file1.ts +/user/username/projects/myproject/Project/file2.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/Project/file2.ts + +WatchedFiles:: +/user/username/projects/myproject/project/tsconfig.json: + {"fileName":"/user/username/projects/myproject/Project/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/project/file1.ts: + {"fileName":"/user/username/projects/myproject/Project/file1.ts","pollingInterval":250} +/a/lib/lib.d.ts: + {"fileName":"/a/lib/lib.d.ts","pollingInterval":250} +/user/username/projects/myproject/project/file2.ts: + {"fileName":"/user/username/projects/myproject/Project/file2.ts","pollingInterval":250} + +FsWatches:: + +FsWatchesRecursive:: +/user/username/projects/myproject/project/node_modules/@types: + {"directoryName":"/user/username/projects/myproject/Project/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} +/user/username/projects/myproject/node_modules/@types: + {"directoryName":"/user/username/projects/myproject/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} +/user/username/projects/myproject/project: + {"directoryName":"/user/username/projects/myproject/project","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/Project/file2.js] +"use strict"; +exports.__esModule = true; +exports.y = void 0; +exports.y = 10; + +