From 6756f239e7bfddc4e637026fcfa97424d1570220 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 14 Jun 2024 12:21:32 -0700 Subject: [PATCH] Temp TODO: watch, - watch files, cache timestamps, mutate on program update TODO: Non Incremental buildInfo addition and use May be add package.json to buildInfo and use that for package.json lookups --- src/compiler/tsbuildPublic.ts | 91 +++++--- .../unittests/tsbuild/moduleResolution.ts | 34 +++ .../tsbuildWatch/moduleResolution.ts | 34 +++ ...additional-file-update-with-incremental.js | 208 ++++++++++++++++++ .../handles-additional-file-update.js | 117 ++++++++++ ...additional-file-update-with-incremental.js | 184 ++++++++++++++++ .../outFile/handles-additional-file-update.js | 118 ++++++++++ ...additional-file-update-with-incremental.js | 170 ++++++++++++++ .../handles-additional-file-update.js | 138 ++++++++++++ ...additional-file-update-with-incremental.js | 156 +++++++++++++ .../outFile/handles-additional-file-update.js | 137 ++++++++++++ 11 files changed, 1352 insertions(+), 35 deletions(-) create mode 100644 tests/baselines/reference/tsbuild/moduleResolution/multiFile/handles-additional-file-update-with-incremental.js create mode 100644 tests/baselines/reference/tsbuild/moduleResolution/multiFile/handles-additional-file-update.js create mode 100644 tests/baselines/reference/tsbuild/moduleResolution/outFile/handles-additional-file-update-with-incremental.js create mode 100644 tests/baselines/reference/tsbuild/moduleResolution/outFile/handles-additional-file-update.js create mode 100644 tests/baselines/reference/tsbuildWatch/moduleResolution/multiFile/handles-additional-file-update-with-incremental.js create mode 100644 tests/baselines/reference/tsbuildWatch/moduleResolution/multiFile/handles-additional-file-update.js create mode 100644 tests/baselines/reference/tsbuildWatch/moduleResolution/outFile/handles-additional-file-update-with-incremental.js create mode 100644 tests/baselines/reference/tsbuildWatch/moduleResolution/outFile/handles-additional-file-update.js diff --git a/src/compiler/tsbuildPublic.ts b/src/compiler/tsbuildPublic.ts index 041676f2541..b9473502e43 100644 --- a/src/compiler/tsbuildPublic.ts +++ b/src/compiler/tsbuildPublic.ts @@ -1591,44 +1591,14 @@ function getUpToDateStatusWorker(state: SolutionBuilde let buildInfoVersionMap: ReturnType | undefined; // Get timestamps of input files for (const inputFile of project.fileNames) { - const inputTime = getModifiedTime(state, inputFile); - if (inputTime === missingFileModifiedTime) { - return { - type: UpToDateStatusType.Unbuildable, - reason: `${inputFile} does not exist`, - }; - } - - const inputPath = toPath(state, inputFile); - // If an buildInfo is older than the newest input, we can stop checking - if (buildInfoTime < inputTime) { - let version: string | undefined; - let currentVersion: string | undefined; - if (incrementalBuildInfo) { - // Read files and see if they are same, read is anyways cached - if (!buildInfoVersionMap) buildInfoVersionMap = getBuildInfoFileVersionMap(incrementalBuildInfo, buildInfoPath, host); - const resolvedInputPath = buildInfoVersionMap.roots.get(inputPath); - version = buildInfoVersionMap.fileInfos.get(resolvedInputPath ?? inputPath); - const text = version ? state.readFileWithCache(resolvedInputPath ?? inputFile) : undefined; - currentVersion = text !== undefined ? getSourceFileVersionAsHashFromText(host, text) : undefined; - if (version && version === currentVersion) pseudoInputUpToDate = true; - } - - if (!version || version !== currentVersion) { - return { - type: UpToDateStatusType.OutOfDateWithSelf, - outOfDateOutputFileName: buildInfoPath, - newerInputFileName: inputFile, - }; - } - } - - if (inputTime > newestInputFileTime) { + const statusOrInputInfo = verifyInputFile(inputFile); + if (isUpToDateStatus(statusOrInputInfo)) return statusOrInputInfo; + if (statusOrInputInfo.inputTime > newestInputFileTime) { newestInputFileName = inputFile; - newestInputFileTime = inputTime; + newestInputFileTime = statusOrInputInfo.inputTime; } - seenRoots.add(inputPath); + seenRoots.add(statusOrInputInfo.inputPath); } let existingRoot; @@ -1748,6 +1718,18 @@ function getUpToDateStatusWorker(state: SolutionBuilde ); if (dependentPackageFileStatus) return dependentPackageFileStatus; + // Check if all the additional files in the program are uptodate with buildInfo + if (incrementalBuildInfo) { + // DO we watch these? + buildInfoVersionMap ??= getBuildInfoFileVersionMap(incrementalBuildInfo, buildInfoPath, host); + const additionalFilesStatus = forEachEntry(buildInfoVersionMap.fileInfos, (_version, path) => { + if (seenRoots.has(path)) return undefined; + const statusOrInputInfo = verifyInputFile(path); + return isUpToDateStatus(statusOrInputInfo) ? statusOrInputInfo : undefined; + }); + if (additionalFilesStatus) return additionalFilesStatus; + } + // Up to date return { type: pseudoUpToDate ? @@ -1759,6 +1741,45 @@ function getUpToDateStatusWorker(state: SolutionBuilde newestInputFileName, oldestOutputFileName, }; + + function verifyInputFile(inputFile: string): UpToDateStatus | { inputTime: Date; inputPath: Path; } { + const inputTime = getModifiedTime(state, inputFile); + if (inputTime === missingFileModifiedTime) { + return { + type: UpToDateStatusType.Unbuildable, + reason: `${inputFile} does not exist`, + }; + } + + const inputPath = toPath(state, inputFile); + // If an buildInfo is older than the newest input, we can stop checking + if (buildInfoTime < inputTime) { + let version: string | undefined; + let currentVersion: string | undefined; + if (incrementalBuildInfo) { + // Read files and see if they are same, read is anyways cached + buildInfoVersionMap ??= getBuildInfoFileVersionMap(incrementalBuildInfo, buildInfoPath, host); + const resolvedInputPath = buildInfoVersionMap.roots.get(inputPath); + version = buildInfoVersionMap.fileInfos.get(resolvedInputPath ?? inputPath); + const text = version ? state.readFileWithCache(resolvedInputPath ?? inputFile) : undefined; + currentVersion = text !== undefined ? getSourceFileVersionAsHashFromText(host, text) : undefined; + if (version && version === currentVersion) pseudoInputUpToDate = true; + } + + if (!version || version !== currentVersion) { + return { + type: UpToDateStatusType.OutOfDateWithSelf, + outOfDateOutputFileName: buildInfoPath, + newerInputFileName: inputFile, + }; + } + } + return { inputTime, inputPath }; + } + + function isUpToDateStatus(statusOrInputInfo: ReturnType): statusOrInputInfo is UpToDateStatus { + return !!(statusOrInputInfo as UpToDateStatus).type; + } } function hasSameBuildInfo(state: SolutionBuilderState, buildInfoCacheEntry: BuildInfoCacheEntry, resolvedRefPath: ResolvedConfigFilePath) { diff --git a/src/testRunner/unittests/tsbuild/moduleResolution.ts b/src/testRunner/unittests/tsbuild/moduleResolution.ts index 9ffac36f535..f68f9c7dc0c 100644 --- a/src/testRunner/unittests/tsbuild/moduleResolution.ts +++ b/src/testRunner/unittests/tsbuild/moduleResolution.ts @@ -4,6 +4,7 @@ import { Symlink } from "../../_namespaces/vfs.js"; import { jsonToReadableText } from "../helpers.js"; import { noChangeOnlyRuns, + noChangeRun, verifyTsc, } from "../helpers/tsc.js"; import { verifyTscWatch } from "../helpers/tscWatch.js"; @@ -198,3 +199,36 @@ describe("unittests:: tsbuild:: moduleResolution:: resolution sharing", () => { }], }); }); + +describe("unittests:: tsbuild:: moduleResolution:: handles additional file update sheetal", () => { + [{ incremental: true }, {}].forEach(compilerOptions => { + [{}, { outFile: "../outFile.js" }].forEach(outFileOptions => { + verifyTsc({ + scenario: "moduleResolution", + subScenario: `${outFileOptions.outFile ? "outFile" : "multiFile"}/handles additional file update${compilerOptions.incremental ? " with incremental" : ""}`, + fs: () => + loadProjectFromFiles({ + "/src/projects/a/src/index.ts": "", + "/src/projects/a/tsconfig.json": jsonToReadableText({ + compilerOptions: { strict: true, ...compilerOptions, ...outFileOptions }, + }), + "/src/projects/node_modules/@types/pg/index.d.ts": "export function foo(): void;", + "/src/projects/node_modules/@types/pg/package.json": jsonToReadableText({ + name: "@types/pg", + types: "index.d.ts", + }), + }), + commandLineArgs: ["-b", "/src/projects/a", "--verbose", "--traceResolution", "--explainFiles"], + edits: [ + noChangeRun, + { + caption: "update package", + edit: fs => { + fs.writeFileSync("/src/projects/node_modules/@types/pg/index.d.ts", "export function foo(): void; export function bar(): void;"); + }, + }, + ], + }); + }); + }); +}); diff --git a/src/testRunner/unittests/tsbuildWatch/moduleResolution.ts b/src/testRunner/unittests/tsbuildWatch/moduleResolution.ts index 65cad814764..8c9faaf1a62 100644 --- a/src/testRunner/unittests/tsbuildWatch/moduleResolution.ts +++ b/src/testRunner/unittests/tsbuildWatch/moduleResolution.ts @@ -229,4 +229,38 @@ describe("unittests:: tsbuildWatch:: watchMode:: moduleResolution", () => { }, ], }); + + describe("unittests:: tsbuild:: moduleResolution:: handles additional file update sheetal", () => { + [{ incremental: true }, {}].forEach(compilerOptions => { + [{}, { outFile: "../outFile.js" }].forEach(outFileOptions => { + verifyTscWatch({ + scenario: "moduleResolution", + subScenario: `${outFileOptions.outFile ? "outFile" : "multiFile"}/handles additional file update${compilerOptions.incremental ? " with incremental" : ""}`, + sys: () => + createWatchedSystem({ + "/src/projects/a/src/index.ts": "", + "/src/projects/a/tsconfig.json": jsonToReadableText({ + compilerOptions: { strict: true, ...compilerOptions, ...outFileOptions }, + }), + "/src/projects/node_modules/@types/pg/index.d.ts": "export function foo(): void;", + "/src/projects/node_modules/@types/pg/package.json": jsonToReadableText({ + name: "@types/pg", + types: "index.d.ts", + }), + [libFile.path]: libFile.content, + }, { currentDirectory: "/src/projects/a" }), + commandLineArgs: ["-b", "-w", "--verbose", "--traceResolution", "--explainFiles"], + edits: [ + { + caption: "update package", + edit: sys => { + sys.appendFile("/src/projects/node_modules/@types/pg/index.d.ts", "export function bar(): void;"); + }, + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + ], + }); + }); + }); + }); }); diff --git a/tests/baselines/reference/tsbuild/moduleResolution/multiFile/handles-additional-file-update-with-incremental.js b/tests/baselines/reference/tsbuild/moduleResolution/multiFile/handles-additional-file-update-with-incremental.js new file mode 100644 index 00000000000..ce4ea81ca9a --- /dev/null +++ b/tests/baselines/reference/tsbuild/moduleResolution/multiFile/handles-additional-file-update-with-incremental.js @@ -0,0 +1,208 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Input:: +//// [/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; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + +//// [/src/projects/a/src/index.ts] + + +//// [/src/projects/a/tsconfig.json] +{ + "compilerOptions": { + "strict": true, + "incremental": true + } +} + +//// [/src/projects/node_modules/@types/pg/index.d.ts] +export function foo(): void; + +//// [/src/projects/node_modules/@types/pg/package.json] +{ + "name": "@types/pg", + "types": "index.d.ts" +} + + + +Output:: +/lib/tsc -b /src/projects/a --verbose --traceResolution --explainFiles +[HH:MM:SS AM] Projects in this build: + * src/projects/a/tsconfig.json + +[HH:MM:SS AM] Project 'src/projects/a/tsconfig.json' is out of date because output file 'src/projects/a/tsconfig.tsbuildinfo' does not exist + +[HH:MM:SS AM] Building project '/src/projects/a/tsconfig.json'... + +======== Resolving type reference directive 'pg', containing file '/src/projects/a/__inferred type names__.ts', root directory '/src/projects/a/node_modules/@types,/src/projects/node_modules/@types,/src/node_modules/@types,/node_modules/@types'. ======== +Resolving with primary search path '/src/projects/a/node_modules/@types, /src/projects/node_modules/@types, /src/node_modules/@types, /node_modules/@types'. +Directory '/src/projects/a/node_modules/@types' does not exist, skipping all lookups in it. +Found 'package.json' at '/src/projects/node_modules/@types/pg/package.json'. +'package.json' does not have a 'typesVersions' field. +'package.json' does not have a 'typings' field. +'package.json' has 'types' field 'index.d.ts' that references '/src/projects/node_modules/@types/pg/index.d.ts'. +File '/src/projects/node_modules/@types/pg/index.d.ts' exists - use it as a name resolution result. +Resolving real path for '/src/projects/node_modules/@types/pg/index.d.ts', result '/src/projects/node_modules/@types/pg/index.d.ts'. +======== Type reference directive 'pg' was successfully resolved to '/src/projects/node_modules/@types/pg/index.d.ts', primary: true. ======== +lib/lib.d.ts + Default library for target 'es5' +src/projects/a/src/index.ts + Matched by default include pattern '**/*' +src/projects/node_modules/@types/pg/index.d.ts + Entry point for implicit type library 'pg' +exitCode:: ExitStatus.Success + + +//// [/src/projects/a/src/index.js] +"use strict"; + + +//// [/src/projects/a/tsconfig.tsbuildinfo] +{"fileNames":["../../../lib/lib.d.ts","./src/index.ts","../node_modules/@types/pg/index.d.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"5381-","-691057527-export function foo(): void;"],"root":[2],"options":{"strict":true},"version":"FakeTSVersion"} + +//// [/src/projects/a/tsconfig.tsbuildinfo.readable.baseline.txt] +{ + "fileNames": [ + "../../../lib/lib.d.ts", + "./src/index.ts", + "../node_modules/@types/pg/index.d.ts" + ], + "fileInfos": { + "../../../lib/lib.d.ts": { + "original": { + "version": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true + }, + "version": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "signature": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true + }, + "./src/index.ts": { + "version": "5381-", + "signature": "5381-" + }, + "../node_modules/@types/pg/index.d.ts": { + "version": "-691057527-export function foo(): void;", + "signature": "-691057527-export function foo(): void;" + } + }, + "root": [ + [ + 2, + "./src/index.ts" + ] + ], + "options": { + "strict": true + }, + "version": "FakeTSVersion", + "size": 701 +} + + + +Change:: no-change-run +Input:: + + +Output:: +/lib/tsc -b /src/projects/a --verbose --traceResolution --explainFiles +[HH:MM:SS AM] Projects in this build: + * src/projects/a/tsconfig.json + +[HH:MM:SS AM] Project 'src/projects/a/tsconfig.json' is up to date because newest input 'src/projects/a/src/index.ts' is older than output 'src/projects/a/tsconfig.tsbuildinfo' + +exitCode:: ExitStatus.Success + + + + +Change:: update package +Input:: +//// [/src/projects/node_modules/@types/pg/index.d.ts] +export function foo(): void; export function bar(): void; + + + +Output:: +/lib/tsc -b /src/projects/a --verbose --traceResolution --explainFiles +[HH:MM:SS AM] Projects in this build: + * src/projects/a/tsconfig.json + +[HH:MM:SS AM] Project 'src/projects/a/tsconfig.json' is out of date because output 'src/projects/a/tsconfig.tsbuildinfo' is older than input 'src/projects/node_modules/@types/pg/index.d.ts' + +[HH:MM:SS AM] Building project '/src/projects/a/tsconfig.json'... + +======== Resolving type reference directive 'pg', containing file '/src/projects/a/__inferred type names__.ts', root directory '/src/projects/a/node_modules/@types,/src/projects/node_modules/@types,/src/node_modules/@types,/node_modules/@types'. ======== +Resolving with primary search path '/src/projects/a/node_modules/@types, /src/projects/node_modules/@types, /src/node_modules/@types, /node_modules/@types'. +Directory '/src/projects/a/node_modules/@types' does not exist, skipping all lookups in it. +Found 'package.json' at '/src/projects/node_modules/@types/pg/package.json'. +'package.json' does not have a 'typesVersions' field. +'package.json' does not have a 'typings' field. +'package.json' has 'types' field 'index.d.ts' that references '/src/projects/node_modules/@types/pg/index.d.ts'. +File '/src/projects/node_modules/@types/pg/index.d.ts' exists - use it as a name resolution result. +Resolving real path for '/src/projects/node_modules/@types/pg/index.d.ts', result '/src/projects/node_modules/@types/pg/index.d.ts'. +======== Type reference directive 'pg' was successfully resolved to '/src/projects/node_modules/@types/pg/index.d.ts', primary: true. ======== +lib/lib.d.ts + Default library for target 'es5' +src/projects/a/src/index.ts + Matched by default include pattern '**/*' +src/projects/node_modules/@types/pg/index.d.ts + Entry point for implicit type library 'pg' +exitCode:: ExitStatus.Success + + +//// [/src/projects/a/tsconfig.tsbuildinfo] +{"fileNames":["../../../lib/lib.d.ts","./src/index.ts","../node_modules/@types/pg/index.d.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"5381-","-10634348642-export function foo(): void; export function bar(): void;"],"root":[2],"options":{"strict":true},"version":"FakeTSVersion"} + +//// [/src/projects/a/tsconfig.tsbuildinfo.readable.baseline.txt] +{ + "fileNames": [ + "../../../lib/lib.d.ts", + "./src/index.ts", + "../node_modules/@types/pg/index.d.ts" + ], + "fileInfos": { + "../../../lib/lib.d.ts": { + "original": { + "version": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true + }, + "version": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "signature": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true + }, + "./src/index.ts": { + "version": "5381-", + "signature": "5381-" + }, + "../node_modules/@types/pg/index.d.ts": { + "version": "-10634348642-export function foo(): void; export function bar(): void;", + "signature": "-10634348642-export function foo(): void; export function bar(): void;" + } + }, + "root": [ + [ + 2, + "./src/index.ts" + ] + ], + "options": { + "strict": true + }, + "version": "FakeTSVersion", + "size": 732 +} + diff --git a/tests/baselines/reference/tsbuild/moduleResolution/multiFile/handles-additional-file-update.js b/tests/baselines/reference/tsbuild/moduleResolution/multiFile/handles-additional-file-update.js new file mode 100644 index 00000000000..9ca2db81b2c --- /dev/null +++ b/tests/baselines/reference/tsbuild/moduleResolution/multiFile/handles-additional-file-update.js @@ -0,0 +1,117 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Input:: +//// [/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; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + +//// [/src/projects/a/src/index.ts] + + +//// [/src/projects/a/tsconfig.json] +{ + "compilerOptions": { + "strict": true + } +} + +//// [/src/projects/node_modules/@types/pg/index.d.ts] +export function foo(): void; + +//// [/src/projects/node_modules/@types/pg/package.json] +{ + "name": "@types/pg", + "types": "index.d.ts" +} + + + +Output:: +/lib/tsc -b /src/projects/a --verbose --traceResolution --explainFiles +[HH:MM:SS AM] Projects in this build: + * src/projects/a/tsconfig.json + +[HH:MM:SS AM] Project 'src/projects/a/tsconfig.json' is out of date because output file 'src/projects/a/tsconfig.tsbuildinfo' does not exist + +[HH:MM:SS AM] Building project '/src/projects/a/tsconfig.json'... + +======== Resolving type reference directive 'pg', containing file '/src/projects/a/__inferred type names__.ts', root directory '/src/projects/a/node_modules/@types,/src/projects/node_modules/@types,/src/node_modules/@types,/node_modules/@types'. ======== +Resolving with primary search path '/src/projects/a/node_modules/@types, /src/projects/node_modules/@types, /src/node_modules/@types, /node_modules/@types'. +Directory '/src/projects/a/node_modules/@types' does not exist, skipping all lookups in it. +Found 'package.json' at '/src/projects/node_modules/@types/pg/package.json'. +'package.json' does not have a 'typesVersions' field. +'package.json' does not have a 'typings' field. +'package.json' has 'types' field 'index.d.ts' that references '/src/projects/node_modules/@types/pg/index.d.ts'. +File '/src/projects/node_modules/@types/pg/index.d.ts' exists - use it as a name resolution result. +Resolving real path for '/src/projects/node_modules/@types/pg/index.d.ts', result '/src/projects/node_modules/@types/pg/index.d.ts'. +======== Type reference directive 'pg' was successfully resolved to '/src/projects/node_modules/@types/pg/index.d.ts', primary: true. ======== +lib/lib.d.ts + Default library for target 'es5' +src/projects/a/src/index.ts + Matched by default include pattern '**/*' +src/projects/node_modules/@types/pg/index.d.ts + Entry point for implicit type library 'pg' +exitCode:: ExitStatus.Success + + +//// [/src/projects/a/src/index.js] +"use strict"; + + +//// [/src/projects/a/tsconfig.tsbuildinfo] +{"root":["./src/index.ts"],"version":"FakeTSVersion"} + +//// [/src/projects/a/tsconfig.tsbuildinfo.readable.baseline.txt] +{ + "root": [ + "./src/index.ts" + ], + "version": "FakeTSVersion", + "size": 53 +} + + + +Change:: no-change-run +Input:: + + +Output:: +/lib/tsc -b /src/projects/a --verbose --traceResolution --explainFiles +[HH:MM:SS AM] Projects in this build: + * src/projects/a/tsconfig.json + +[HH:MM:SS AM] Project 'src/projects/a/tsconfig.json' is up to date because newest input 'src/projects/a/src/index.ts' is older than output 'src/projects/a/src/index.js' + +exitCode:: ExitStatus.Success + + + + +Change:: update package +Input:: +//// [/src/projects/node_modules/@types/pg/index.d.ts] +export function foo(): void; export function bar(): void; + + + +Output:: +/lib/tsc -b /src/projects/a --verbose --traceResolution --explainFiles +[HH:MM:SS AM] Projects in this build: + * src/projects/a/tsconfig.json + +[HH:MM:SS AM] Project 'src/projects/a/tsconfig.json' is up to date because newest input 'src/projects/a/src/index.ts' is older than output 'src/projects/a/src/index.js' + +exitCode:: ExitStatus.Success + + diff --git a/tests/baselines/reference/tsbuild/moduleResolution/outFile/handles-additional-file-update-with-incremental.js b/tests/baselines/reference/tsbuild/moduleResolution/outFile/handles-additional-file-update-with-incremental.js new file mode 100644 index 00000000000..d01ee4243dd --- /dev/null +++ b/tests/baselines/reference/tsbuild/moduleResolution/outFile/handles-additional-file-update-with-incremental.js @@ -0,0 +1,184 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Input:: +//// [/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; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + +//// [/src/projects/a/src/index.ts] + + +//// [/src/projects/a/tsconfig.json] +{ + "compilerOptions": { + "strict": true, + "incremental": true, + "outFile": "../outFile.js" + } +} + +//// [/src/projects/node_modules/@types/pg/index.d.ts] +export function foo(): void; + +//// [/src/projects/node_modules/@types/pg/package.json] +{ + "name": "@types/pg", + "types": "index.d.ts" +} + + + +Output:: +/lib/tsc -b /src/projects/a --verbose --traceResolution --explainFiles +[HH:MM:SS AM] Projects in this build: + * src/projects/a/tsconfig.json + +[HH:MM:SS AM] Project 'src/projects/a/tsconfig.json' is out of date because output file 'src/projects/outFile.tsbuildinfo' does not exist + +[HH:MM:SS AM] Building project '/src/projects/a/tsconfig.json'... + +======== Resolving type reference directive 'pg', containing file '/src/projects/a/__inferred type names__.ts', root directory '/src/projects/a/node_modules/@types,/src/projects/node_modules/@types,/src/node_modules/@types,/node_modules/@types'. ======== +Resolving with primary search path '/src/projects/a/node_modules/@types, /src/projects/node_modules/@types, /src/node_modules/@types, /node_modules/@types'. +Directory '/src/projects/a/node_modules/@types' does not exist, skipping all lookups in it. +Found 'package.json' at '/src/projects/node_modules/@types/pg/package.json'. +'package.json' does not have a 'typesVersions' field. +'package.json' does not have a 'typings' field. +'package.json' has 'types' field 'index.d.ts' that references '/src/projects/node_modules/@types/pg/index.d.ts'. +File '/src/projects/node_modules/@types/pg/index.d.ts' exists - use it as a name resolution result. +Resolving real path for '/src/projects/node_modules/@types/pg/index.d.ts', result '/src/projects/node_modules/@types/pg/index.d.ts'. +======== Type reference directive 'pg' was successfully resolved to '/src/projects/node_modules/@types/pg/index.d.ts', primary: true. ======== +lib/lib.d.ts + Default library for target 'es5' +src/projects/a/src/index.ts + Matched by default include pattern '**/*' +src/projects/node_modules/@types/pg/index.d.ts + Entry point for implicit type library 'pg' +exitCode:: ExitStatus.Success + + +//// [/src/projects/outFile.js] +"use strict"; + + +//// [/src/projects/outFile.tsbuildinfo] +{"fileNames":["../../lib/lib.d.ts","./a/src/index.ts","./node_modules/@types/pg/index.d.ts"],"fileInfos":["3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","5381-","-691057527-export function foo(): void;"],"root":[2],"options":{"outFile":"./outFile.js","strict":true},"version":"FakeTSVersion"} + +//// [/src/projects/outFile.tsbuildinfo.readable.baseline.txt] +{ + "fileNames": [ + "../../lib/lib.d.ts", + "./a/src/index.ts", + "./node_modules/@types/pg/index.d.ts" + ], + "fileInfos": { + "../../lib/lib.d.ts": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "./a/src/index.ts": "5381-", + "./node_modules/@types/pg/index.d.ts": "-691057527-export function foo(): void;" + }, + "root": [ + [ + 2, + "./a/src/index.ts" + ] + ], + "options": { + "outFile": "./outFile.js", + "strict": true + }, + "version": "FakeTSVersion", + "size": 686 +} + + + +Change:: no-change-run +Input:: + + +Output:: +/lib/tsc -b /src/projects/a --verbose --traceResolution --explainFiles +[HH:MM:SS AM] Projects in this build: + * src/projects/a/tsconfig.json + +[HH:MM:SS AM] Project 'src/projects/a/tsconfig.json' is up to date because newest input 'src/projects/a/src/index.ts' is older than output 'src/projects/outFile.tsbuildinfo' + +exitCode:: ExitStatus.Success + + + + +Change:: update package +Input:: +//// [/src/projects/node_modules/@types/pg/index.d.ts] +export function foo(): void; export function bar(): void; + + + +Output:: +/lib/tsc -b /src/projects/a --verbose --traceResolution --explainFiles +[HH:MM:SS AM] Projects in this build: + * src/projects/a/tsconfig.json + +[HH:MM:SS AM] Project 'src/projects/a/tsconfig.json' is out of date because output 'src/projects/outFile.tsbuildinfo' is older than input 'src/projects/node_modules/@types/pg/index.d.ts' + +[HH:MM:SS AM] Building project '/src/projects/a/tsconfig.json'... + +======== Resolving type reference directive 'pg', containing file '/src/projects/a/__inferred type names__.ts', root directory '/src/projects/a/node_modules/@types,/src/projects/node_modules/@types,/src/node_modules/@types,/node_modules/@types'. ======== +Resolving with primary search path '/src/projects/a/node_modules/@types, /src/projects/node_modules/@types, /src/node_modules/@types, /node_modules/@types'. +Directory '/src/projects/a/node_modules/@types' does not exist, skipping all lookups in it. +Found 'package.json' at '/src/projects/node_modules/@types/pg/package.json'. +'package.json' does not have a 'typesVersions' field. +'package.json' does not have a 'typings' field. +'package.json' has 'types' field 'index.d.ts' that references '/src/projects/node_modules/@types/pg/index.d.ts'. +File '/src/projects/node_modules/@types/pg/index.d.ts' exists - use it as a name resolution result. +Resolving real path for '/src/projects/node_modules/@types/pg/index.d.ts', result '/src/projects/node_modules/@types/pg/index.d.ts'. +======== Type reference directive 'pg' was successfully resolved to '/src/projects/node_modules/@types/pg/index.d.ts', primary: true. ======== +lib/lib.d.ts + Default library for target 'es5' +src/projects/a/src/index.ts + Matched by default include pattern '**/*' +src/projects/node_modules/@types/pg/index.d.ts + Entry point for implicit type library 'pg' +exitCode:: ExitStatus.Success + + +//// [/src/projects/outFile.js] file written with same contents +//// [/src/projects/outFile.tsbuildinfo] +{"fileNames":["../../lib/lib.d.ts","./a/src/index.ts","./node_modules/@types/pg/index.d.ts"],"fileInfos":["3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","5381-","-10634348642-export function foo(): void; export function bar(): void;"],"root":[2],"options":{"outFile":"./outFile.js","strict":true},"version":"FakeTSVersion"} + +//// [/src/projects/outFile.tsbuildinfo.readable.baseline.txt] +{ + "fileNames": [ + "../../lib/lib.d.ts", + "./a/src/index.ts", + "./node_modules/@types/pg/index.d.ts" + ], + "fileInfos": { + "../../lib/lib.d.ts": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "./a/src/index.ts": "5381-", + "./node_modules/@types/pg/index.d.ts": "-10634348642-export function foo(): void; export function bar(): void;" + }, + "root": [ + [ + 2, + "./a/src/index.ts" + ] + ], + "options": { + "outFile": "./outFile.js", + "strict": true + }, + "version": "FakeTSVersion", + "size": 717 +} + diff --git a/tests/baselines/reference/tsbuild/moduleResolution/outFile/handles-additional-file-update.js b/tests/baselines/reference/tsbuild/moduleResolution/outFile/handles-additional-file-update.js new file mode 100644 index 00000000000..e14b50187b7 --- /dev/null +++ b/tests/baselines/reference/tsbuild/moduleResolution/outFile/handles-additional-file-update.js @@ -0,0 +1,118 @@ +currentDirectory:: / useCaseSensitiveFileNames: false +Input:: +//// [/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; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + +//// [/src/projects/a/src/index.ts] + + +//// [/src/projects/a/tsconfig.json] +{ + "compilerOptions": { + "strict": true, + "outFile": "../outFile.js" + } +} + +//// [/src/projects/node_modules/@types/pg/index.d.ts] +export function foo(): void; + +//// [/src/projects/node_modules/@types/pg/package.json] +{ + "name": "@types/pg", + "types": "index.d.ts" +} + + + +Output:: +/lib/tsc -b /src/projects/a --verbose --traceResolution --explainFiles +[HH:MM:SS AM] Projects in this build: + * src/projects/a/tsconfig.json + +[HH:MM:SS AM] Project 'src/projects/a/tsconfig.json' is out of date because output file 'src/projects/outFile.tsbuildinfo' does not exist + +[HH:MM:SS AM] Building project '/src/projects/a/tsconfig.json'... + +======== Resolving type reference directive 'pg', containing file '/src/projects/a/__inferred type names__.ts', root directory '/src/projects/a/node_modules/@types,/src/projects/node_modules/@types,/src/node_modules/@types,/node_modules/@types'. ======== +Resolving with primary search path '/src/projects/a/node_modules/@types, /src/projects/node_modules/@types, /src/node_modules/@types, /node_modules/@types'. +Directory '/src/projects/a/node_modules/@types' does not exist, skipping all lookups in it. +Found 'package.json' at '/src/projects/node_modules/@types/pg/package.json'. +'package.json' does not have a 'typesVersions' field. +'package.json' does not have a 'typings' field. +'package.json' has 'types' field 'index.d.ts' that references '/src/projects/node_modules/@types/pg/index.d.ts'. +File '/src/projects/node_modules/@types/pg/index.d.ts' exists - use it as a name resolution result. +Resolving real path for '/src/projects/node_modules/@types/pg/index.d.ts', result '/src/projects/node_modules/@types/pg/index.d.ts'. +======== Type reference directive 'pg' was successfully resolved to '/src/projects/node_modules/@types/pg/index.d.ts', primary: true. ======== +lib/lib.d.ts + Default library for target 'es5' +src/projects/a/src/index.ts + Matched by default include pattern '**/*' +src/projects/node_modules/@types/pg/index.d.ts + Entry point for implicit type library 'pg' +exitCode:: ExitStatus.Success + + +//// [/src/projects/outFile.js] +"use strict"; + + +//// [/src/projects/outFile.tsbuildinfo] +{"root":["./a/src/index.ts"],"version":"FakeTSVersion"} + +//// [/src/projects/outFile.tsbuildinfo.readable.baseline.txt] +{ + "root": [ + "./a/src/index.ts" + ], + "version": "FakeTSVersion", + "size": 55 +} + + + +Change:: no-change-run +Input:: + + +Output:: +/lib/tsc -b /src/projects/a --verbose --traceResolution --explainFiles +[HH:MM:SS AM] Projects in this build: + * src/projects/a/tsconfig.json + +[HH:MM:SS AM] Project 'src/projects/a/tsconfig.json' is up to date because newest input 'src/projects/a/src/index.ts' is older than output 'src/projects/outFile.js' + +exitCode:: ExitStatus.Success + + + + +Change:: update package +Input:: +//// [/src/projects/node_modules/@types/pg/index.d.ts] +export function foo(): void; export function bar(): void; + + + +Output:: +/lib/tsc -b /src/projects/a --verbose --traceResolution --explainFiles +[HH:MM:SS AM] Projects in this build: + * src/projects/a/tsconfig.json + +[HH:MM:SS AM] Project 'src/projects/a/tsconfig.json' is up to date because newest input 'src/projects/a/src/index.ts' is older than output 'src/projects/outFile.js' + +exitCode:: ExitStatus.Success + + diff --git a/tests/baselines/reference/tsbuildWatch/moduleResolution/multiFile/handles-additional-file-update-with-incremental.js b/tests/baselines/reference/tsbuildWatch/moduleResolution/multiFile/handles-additional-file-update-with-incremental.js new file mode 100644 index 00000000000..d51fe892712 --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/moduleResolution/multiFile/handles-additional-file-update-with-incremental.js @@ -0,0 +1,170 @@ +currentDirectory:: /src/projects/a useCaseSensitiveFileNames: false +Input:: +//// [/src/projects/a/src/index.ts] + + +//// [/src/projects/a/tsconfig.json] +{ + "compilerOptions": { + "strict": true, + "incremental": true + } +} + +//// [/src/projects/node_modules/@types/pg/index.d.ts] +export function foo(): void; + +//// [/src/projects/node_modules/@types/pg/package.json] +{ + "name": "@types/pg", + "types": "index.d.ts" +} + +//// [/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; } + + +/a/lib/tsc.js -b -w --verbose --traceResolution --explainFiles +Output:: +>> Screen clear +[HH:MM:SS AM] Starting compilation in watch mode... + +[HH:MM:SS AM] Projects in this build: + * tsconfig.json + +[HH:MM:SS AM] Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist + +[HH:MM:SS AM] Building project '/src/projects/a/tsconfig.json'... + +======== Resolving type reference directive 'pg', containing file '/src/projects/a/__inferred type names__.ts', root directory '/src/projects/a/node_modules/@types,/src/projects/node_modules/@types,/src/node_modules/@types,/node_modules/@types'. ======== +Resolving with primary search path '/src/projects/a/node_modules/@types, /src/projects/node_modules/@types, /src/node_modules/@types, /node_modules/@types'. +Directory '/src/projects/a/node_modules/@types' does not exist, skipping all lookups in it. +Found 'package.json' at '/src/projects/node_modules/@types/pg/package.json'. +'package.json' does not have a 'typesVersions' field. +'package.json' does not have a 'typings' field. +'package.json' has 'types' field 'index.d.ts' that references '/src/projects/node_modules/@types/pg/index.d.ts'. +File '/src/projects/node_modules/@types/pg/index.d.ts' exists - use it as a name resolution result. +Resolving real path for '/src/projects/node_modules/@types/pg/index.d.ts', result '/src/projects/node_modules/@types/pg/index.d.ts'. +======== Type reference directive 'pg' was successfully resolved to '/src/projects/node_modules/@types/pg/index.d.ts', primary: true. ======== +../../../a/lib/lib.d.ts + Default library for target 'es5' +src/index.ts + Matched by default include pattern '**/*' +../node_modules/@types/pg/index.d.ts + Entry point for implicit type library 'pg' +[HH:MM:SS AM] Found 0 errors. Watching for file changes. + + + +//// [/src/projects/a/src/index.js] +"use strict"; + + +//// [/src/projects/a/tsconfig.tsbuildinfo] +{"fileNames":["../../../a/lib/lib.d.ts","./src/index.ts","../node_modules/@types/pg/index.d.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true},"5381-","-691057527-export function foo(): void;"],"root":[2],"options":{"strict":true},"version":"FakeTSVersion"} + +//// [/src/projects/a/tsconfig.tsbuildinfo.readable.baseline.txt] +{ + "fileNames": [ + "../../../a/lib/lib.d.ts", + "./src/index.ts", + "../node_modules/@types/pg/index.d.ts" + ], + "fileInfos": { + "../../../a/lib/lib.d.ts": { + "original": { + "version": "-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }", + "affectsGlobalScope": true + }, + "version": "-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }", + "signature": "-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }", + "affectsGlobalScope": true + }, + "./src/index.ts": { + "version": "5381-", + "signature": "5381-" + }, + "../node_modules/@types/pg/index.d.ts": { + "version": "-691057527-export function foo(): void;", + "signature": "-691057527-export function foo(): void;" + } + }, + "root": [ + [ + 2, + "./src/index.ts" + ] + ], + "options": { + "strict": true + }, + "version": "FakeTSVersion", + "size": 623 +} + + +FsWatches:: +/src/projects/a/src/index.ts: *new* + {} +/src/projects/a/tsconfig.json: *new* + {} +/src/projects/node_modules/@types/pg/package.json: *new* + {} + +FsWatchesRecursive:: +/src/projects/a: *new* + {} + +Program root files: [ + "/src/projects/a/src/index.ts" +] +Program options: { + "strict": true, + "incremental": true, + "watch": true, + "explainFiles": true, + "traceResolution": true, + "tscBuild": true, + "configFilePath": "/src/projects/a/tsconfig.json" +} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/src/projects/a/src/index.ts +/src/projects/node_modules/@types/pg/index.d.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/src/projects/a/src/index.ts +/src/projects/node_modules/@types/pg/index.d.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/src/projects/a/src/index.ts (used version) +/src/projects/node_modules/@types/pg/index.d.ts (used version) + +exitCode:: ExitStatus.undefined + +Change:: update package + +Input:: +//// [/src/projects/node_modules/@types/pg/index.d.ts] +export function foo(): void;export function bar(): void; + + +Before running Timeout callback:: count: 0 + +After running Timeout callback:: count: 0 + + +exitCode:: ExitStatus.undefined diff --git a/tests/baselines/reference/tsbuildWatch/moduleResolution/multiFile/handles-additional-file-update.js b/tests/baselines/reference/tsbuildWatch/moduleResolution/multiFile/handles-additional-file-update.js new file mode 100644 index 00000000000..5f8db68bbf3 --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/moduleResolution/multiFile/handles-additional-file-update.js @@ -0,0 +1,138 @@ +currentDirectory:: /src/projects/a useCaseSensitiveFileNames: false +Input:: +//// [/src/projects/a/src/index.ts] + + +//// [/src/projects/a/tsconfig.json] +{ + "compilerOptions": { + "strict": true + } +} + +//// [/src/projects/node_modules/@types/pg/index.d.ts] +export function foo(): void; + +//// [/src/projects/node_modules/@types/pg/package.json] +{ + "name": "@types/pg", + "types": "index.d.ts" +} + +//// [/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; } + + +/a/lib/tsc.js -b -w --verbose --traceResolution --explainFiles +Output:: +>> Screen clear +[HH:MM:SS AM] Starting compilation in watch mode... + +[HH:MM:SS AM] Projects in this build: + * tsconfig.json + +[HH:MM:SS AM] Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist + +[HH:MM:SS AM] Building project '/src/projects/a/tsconfig.json'... + +======== Resolving type reference directive 'pg', containing file '/src/projects/a/__inferred type names__.ts', root directory '/src/projects/a/node_modules/@types,/src/projects/node_modules/@types,/src/node_modules/@types,/node_modules/@types'. ======== +Resolving with primary search path '/src/projects/a/node_modules/@types, /src/projects/node_modules/@types, /src/node_modules/@types, /node_modules/@types'. +Directory '/src/projects/a/node_modules/@types' does not exist, skipping all lookups in it. +Found 'package.json' at '/src/projects/node_modules/@types/pg/package.json'. +'package.json' does not have a 'typesVersions' field. +'package.json' does not have a 'typings' field. +'package.json' has 'types' field 'index.d.ts' that references '/src/projects/node_modules/@types/pg/index.d.ts'. +File '/src/projects/node_modules/@types/pg/index.d.ts' exists - use it as a name resolution result. +Resolving real path for '/src/projects/node_modules/@types/pg/index.d.ts', result '/src/projects/node_modules/@types/pg/index.d.ts'. +======== Type reference directive 'pg' was successfully resolved to '/src/projects/node_modules/@types/pg/index.d.ts', primary: true. ======== +../../../a/lib/lib.d.ts + Default library for target 'es5' +src/index.ts + Matched by default include pattern '**/*' +../node_modules/@types/pg/index.d.ts + Entry point for implicit type library 'pg' +[HH:MM:SS AM] Found 0 errors. Watching for file changes. + + + +//// [/src/projects/a/src/index.js] +"use strict"; + + +//// [/src/projects/a/tsconfig.tsbuildinfo] +{"root":["./src/index.ts"],"version":"FakeTSVersion"} + +//// [/src/projects/a/tsconfig.tsbuildinfo.readable.baseline.txt] +{ + "root": [ + "./src/index.ts" + ], + "version": "FakeTSVersion", + "size": 53 +} + + +FsWatches:: +/src/projects/a/src/index.ts: *new* + {} +/src/projects/a/tsconfig.json: *new* + {} +/src/projects/node_modules/@types/pg/package.json: *new* + {} + +FsWatchesRecursive:: +/src/projects/a: *new* + {} + +Program root files: [ + "/src/projects/a/src/index.ts" +] +Program options: { + "strict": true, + "watch": true, + "explainFiles": true, + "traceResolution": true, + "tscBuild": true, + "configFilePath": "/src/projects/a/tsconfig.json" +} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/src/projects/a/src/index.ts +/src/projects/node_modules/@types/pg/index.d.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/src/projects/a/src/index.ts +/src/projects/node_modules/@types/pg/index.d.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/src/projects/a/src/index.ts (used version) +/src/projects/node_modules/@types/pg/index.d.ts (used version) + +exitCode:: ExitStatus.undefined + +Change:: update package + +Input:: +//// [/src/projects/node_modules/@types/pg/index.d.ts] +export function foo(): void;export function bar(): void; + + +Before running Timeout callback:: count: 0 + +After running Timeout callback:: count: 0 + + +exitCode:: ExitStatus.undefined diff --git a/tests/baselines/reference/tsbuildWatch/moduleResolution/outFile/handles-additional-file-update-with-incremental.js b/tests/baselines/reference/tsbuildWatch/moduleResolution/outFile/handles-additional-file-update-with-incremental.js new file mode 100644 index 00000000000..e0113b4780a --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/moduleResolution/outFile/handles-additional-file-update-with-incremental.js @@ -0,0 +1,156 @@ +currentDirectory:: /src/projects/a useCaseSensitiveFileNames: false +Input:: +//// [/src/projects/a/src/index.ts] + + +//// [/src/projects/a/tsconfig.json] +{ + "compilerOptions": { + "strict": true, + "incremental": true, + "outFile": "../outFile.js" + } +} + +//// [/src/projects/node_modules/@types/pg/index.d.ts] +export function foo(): void; + +//// [/src/projects/node_modules/@types/pg/package.json] +{ + "name": "@types/pg", + "types": "index.d.ts" +} + +//// [/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; } + + +/a/lib/tsc.js -b -w --verbose --traceResolution --explainFiles +Output:: +>> Screen clear +[HH:MM:SS AM] Starting compilation in watch mode... + +[HH:MM:SS AM] Projects in this build: + * tsconfig.json + +[HH:MM:SS AM] Project 'tsconfig.json' is out of date because output file '../outFile.tsbuildinfo' does not exist + +[HH:MM:SS AM] Building project '/src/projects/a/tsconfig.json'... + +======== Resolving type reference directive 'pg', containing file '/src/projects/a/__inferred type names__.ts', root directory '/src/projects/a/node_modules/@types,/src/projects/node_modules/@types,/src/node_modules/@types,/node_modules/@types'. ======== +Resolving with primary search path '/src/projects/a/node_modules/@types, /src/projects/node_modules/@types, /src/node_modules/@types, /node_modules/@types'. +Directory '/src/projects/a/node_modules/@types' does not exist, skipping all lookups in it. +Found 'package.json' at '/src/projects/node_modules/@types/pg/package.json'. +'package.json' does not have a 'typesVersions' field. +'package.json' does not have a 'typings' field. +'package.json' has 'types' field 'index.d.ts' that references '/src/projects/node_modules/@types/pg/index.d.ts'. +File '/src/projects/node_modules/@types/pg/index.d.ts' exists - use it as a name resolution result. +Resolving real path for '/src/projects/node_modules/@types/pg/index.d.ts', result '/src/projects/node_modules/@types/pg/index.d.ts'. +======== Type reference directive 'pg' was successfully resolved to '/src/projects/node_modules/@types/pg/index.d.ts', primary: true. ======== +../../../a/lib/lib.d.ts + Default library for target 'es5' +src/index.ts + Matched by default include pattern '**/*' +../node_modules/@types/pg/index.d.ts + Entry point for implicit type library 'pg' +[HH:MM:SS AM] Found 0 errors. Watching for file changes. + + + +//// [/src/projects/outFile.js] +"use strict"; + + +//// [/src/projects/outFile.tsbuildinfo] +{"fileNames":["../../a/lib/lib.d.ts","./a/src/index.ts","./node_modules/@types/pg/index.d.ts"],"fileInfos":["-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","5381-","-691057527-export function foo(): void;"],"root":[2],"options":{"outFile":"./outFile.js","strict":true},"version":"FakeTSVersion"} + +//// [/src/projects/outFile.tsbuildinfo.readable.baseline.txt] +{ + "fileNames": [ + "../../a/lib/lib.d.ts", + "./a/src/index.ts", + "./node_modules/@types/pg/index.d.ts" + ], + "fileInfos": { + "../../a/lib/lib.d.ts": "-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }", + "./a/src/index.ts": "5381-", + "./node_modules/@types/pg/index.d.ts": "-691057527-export function foo(): void;" + }, + "root": [ + [ + 2, + "./a/src/index.ts" + ] + ], + "options": { + "outFile": "./outFile.js", + "strict": true + }, + "version": "FakeTSVersion", + "size": 608 +} + + +FsWatches:: +/src/projects/a/src/index.ts: *new* + {} +/src/projects/a/tsconfig.json: *new* + {} +/src/projects/node_modules/@types/pg/package.json: *new* + {} + +FsWatchesRecursive:: +/src/projects/a: *new* + {} + +Program root files: [ + "/src/projects/a/src/index.ts" +] +Program options: { + "strict": true, + "incremental": true, + "outFile": "/src/projects/outFile.js", + "watch": true, + "explainFiles": true, + "traceResolution": true, + "tscBuild": true, + "configFilePath": "/src/projects/a/tsconfig.json" +} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/src/projects/a/src/index.ts +/src/projects/node_modules/@types/pg/index.d.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/src/projects/a/src/index.ts +/src/projects/node_modules/@types/pg/index.d.ts + +No shapes updated in the builder:: + +exitCode:: ExitStatus.undefined + +Change:: update package + +Input:: +//// [/src/projects/node_modules/@types/pg/index.d.ts] +export function foo(): void;export function bar(): void; + + +Before running Timeout callback:: count: 0 + +After running Timeout callback:: count: 0 + + +exitCode:: ExitStatus.undefined diff --git a/tests/baselines/reference/tsbuildWatch/moduleResolution/outFile/handles-additional-file-update.js b/tests/baselines/reference/tsbuildWatch/moduleResolution/outFile/handles-additional-file-update.js new file mode 100644 index 00000000000..44d5ba3a134 --- /dev/null +++ b/tests/baselines/reference/tsbuildWatch/moduleResolution/outFile/handles-additional-file-update.js @@ -0,0 +1,137 @@ +currentDirectory:: /src/projects/a useCaseSensitiveFileNames: false +Input:: +//// [/src/projects/a/src/index.ts] + + +//// [/src/projects/a/tsconfig.json] +{ + "compilerOptions": { + "strict": true, + "outFile": "../outFile.js" + } +} + +//// [/src/projects/node_modules/@types/pg/index.d.ts] +export function foo(): void; + +//// [/src/projects/node_modules/@types/pg/package.json] +{ + "name": "@types/pg", + "types": "index.d.ts" +} + +//// [/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; } + + +/a/lib/tsc.js -b -w --verbose --traceResolution --explainFiles +Output:: +>> Screen clear +[HH:MM:SS AM] Starting compilation in watch mode... + +[HH:MM:SS AM] Projects in this build: + * tsconfig.json + +[HH:MM:SS AM] Project 'tsconfig.json' is out of date because output file '../outFile.tsbuildinfo' does not exist + +[HH:MM:SS AM] Building project '/src/projects/a/tsconfig.json'... + +======== Resolving type reference directive 'pg', containing file '/src/projects/a/__inferred type names__.ts', root directory '/src/projects/a/node_modules/@types,/src/projects/node_modules/@types,/src/node_modules/@types,/node_modules/@types'. ======== +Resolving with primary search path '/src/projects/a/node_modules/@types, /src/projects/node_modules/@types, /src/node_modules/@types, /node_modules/@types'. +Directory '/src/projects/a/node_modules/@types' does not exist, skipping all lookups in it. +Found 'package.json' at '/src/projects/node_modules/@types/pg/package.json'. +'package.json' does not have a 'typesVersions' field. +'package.json' does not have a 'typings' field. +'package.json' has 'types' field 'index.d.ts' that references '/src/projects/node_modules/@types/pg/index.d.ts'. +File '/src/projects/node_modules/@types/pg/index.d.ts' exists - use it as a name resolution result. +Resolving real path for '/src/projects/node_modules/@types/pg/index.d.ts', result '/src/projects/node_modules/@types/pg/index.d.ts'. +======== Type reference directive 'pg' was successfully resolved to '/src/projects/node_modules/@types/pg/index.d.ts', primary: true. ======== +../../../a/lib/lib.d.ts + Default library for target 'es5' +src/index.ts + Matched by default include pattern '**/*' +../node_modules/@types/pg/index.d.ts + Entry point for implicit type library 'pg' +[HH:MM:SS AM] Found 0 errors. Watching for file changes. + + + +//// [/src/projects/outFile.js] +"use strict"; + + +//// [/src/projects/outFile.tsbuildinfo] +{"root":["./a/src/index.ts"],"version":"FakeTSVersion"} + +//// [/src/projects/outFile.tsbuildinfo.readable.baseline.txt] +{ + "root": [ + "./a/src/index.ts" + ], + "version": "FakeTSVersion", + "size": 55 +} + + +FsWatches:: +/src/projects/a/src/index.ts: *new* + {} +/src/projects/a/tsconfig.json: *new* + {} +/src/projects/node_modules/@types/pg/package.json: *new* + {} + +FsWatchesRecursive:: +/src/projects/a: *new* + {} + +Program root files: [ + "/src/projects/a/src/index.ts" +] +Program options: { + "strict": true, + "outFile": "/src/projects/outFile.js", + "watch": true, + "explainFiles": true, + "traceResolution": true, + "tscBuild": true, + "configFilePath": "/src/projects/a/tsconfig.json" +} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +/src/projects/a/src/index.ts +/src/projects/node_modules/@types/pg/index.d.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/src/projects/a/src/index.ts +/src/projects/node_modules/@types/pg/index.d.ts + +No shapes updated in the builder:: + +exitCode:: ExitStatus.undefined + +Change:: update package + +Input:: +//// [/src/projects/node_modules/@types/pg/index.d.ts] +export function foo(): void;export function bar(): void; + + +Before running Timeout callback:: count: 0 + +After running Timeout callback:: count: 0 + + +exitCode:: ExitStatus.undefined