Skip to content

Commit a455955

Browse files
authoredSep 22, 2022
Make hasInvalidatedResolution non internal for program and add it watchApi (#50776)
* Make stub for hasInvalidatedResolution * Wire through hasInvalidatedResolutions Fixes #48057 * Update comment * Feedback
1 parent 645d1cd commit a455955

File tree

9 files changed

+656
-29
lines changed

9 files changed

+656
-29
lines changed
 

‎src/compiler/resolutionCache.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace ts {
1414
removeResolutionsOfFile(filePath: Path): void;
1515
removeResolutionsFromProjectReferenceRedirects(filePath: Path): void;
1616
setFilesWithInvalidatedNonRelativeUnresolvedImports(filesWithUnresolvedImports: ESMap<Path, readonly string[]>): void;
17-
createHasInvalidatedResolution(forceAllFilesAsInvalidated?: boolean): HasInvalidatedResolution;
17+
createHasInvalidatedResolution(customHasInvalidatedResolution: HasInvalidatedResolution): HasInvalidatedResolution;
1818
hasChangedAutomaticTypeDirectiveNames(): boolean;
1919
isFileWithInvalidatedNonRelativeUnresolvedImports(path: Path): boolean;
2020

@@ -300,17 +300,13 @@ namespace ts {
300300
return !!value && !!value.length;
301301
}
302302

303-
function createHasInvalidatedResolution(forceAllFilesAsInvalidated?: boolean): HasInvalidatedResolution {
303+
function createHasInvalidatedResolution(customHasInvalidatedResolution: HasInvalidatedResolution): HasInvalidatedResolution {
304304
// Ensure pending resolutions are applied
305305
invalidateResolutionsOfFailedLookupLocations();
306-
if (forceAllFilesAsInvalidated) {
307-
// Any file asked would have invalidated resolution
308-
filesWithInvalidatedResolutions = undefined;
309-
return returnTrue;
310-
}
311306
const collected = filesWithInvalidatedResolutions;
312307
filesWithInvalidatedResolutions = undefined;
313-
return path => (!!collected && collected.has(path)) ||
308+
return path => customHasInvalidatedResolution(path) ||
309+
!!collected?.has(path) ||
314310
isFileWithInvalidatedNonRelativeUnresolvedImports(path);
315311
}
316312

‎src/compiler/types.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -7215,7 +7215,8 @@ namespace ts {
72157215
getEnvironmentVariable?(name: string): string | undefined;
72167216
/* @internal */ onReleaseOldSourceFile?(oldSourceFile: SourceFile, oldOptions: CompilerOptions, hasSourceFileByPath: boolean): void;
72177217
/* @internal */ onReleaseParsedCommandLine?(configFileName: string, oldResolvedRef: ResolvedProjectReference | undefined, optionOptions: CompilerOptions): void;
7218-
/* @internal */ hasInvalidatedResolution?: HasInvalidatedResolution;
7218+
/** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */
7219+
hasInvalidatedResolution?(filePath: Path): boolean;
72197220
/* @internal */ hasChangedAutomaticTypeDirectiveNames?: HasChangedAutomaticTypeDirectiveNames;
72207221
createHash?(data: string): string;
72217222
getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined;

‎src/compiler/watchPublic.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ namespace ts {
112112
resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
113113
/** If provided, used to resolve type reference directives, otherwise typescript's default resolution */
114114
resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[];
115+
/** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */
116+
hasInvalidatedResolution?(filePath: Path): boolean;
115117
/**
116118
* Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it
117119
*/
@@ -371,6 +373,10 @@ namespace ts {
371373
maybeBind(host, host.getModuleResolutionCache) :
372374
(() => resolutionCache.getModuleResolutionCache());
373375
const userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
376+
// All resolutions are invalid if user provided resolutions and didnt supply hasInvalidatedResolution
377+
const customHasInvalidatedResolution = userProvidedResolution ?
378+
maybeBind(host, host.hasInvalidatedResolution) || returnTrue :
379+
returnFalse;
374380

375381
builderProgram = readBuilderProgram(compilerOptions, compilerHost) as any as T;
376382
synchronizeProgram();
@@ -443,8 +449,7 @@ namespace ts {
443449
}
444450
}
445451

446-
// All resolutions are invalid if user provided resolutions
447-
const hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
452+
const hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(customHasInvalidatedResolution);
448453
const {
449454
originalReadFile, originalFileExists, originalDirectoryExists,
450455
originalCreateDirectory, originalWriteFile,

‎src/server/project.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ namespace ts.server {
11761176
Debug.assert(!this.isClosed(), "Called update graph worker of closed project");
11771177
this.writeLog(`Starting updateGraphWorker: Project: ${this.getProjectName()}`);
11781178
const start = timestamp();
1179-
this.hasInvalidatedResolution = this.resolutionCache.createHasInvalidatedResolution();
1179+
this.hasInvalidatedResolution = this.resolutionCache.createHasInvalidatedResolution(returnFalse);
11801180
this.resolutionCache.startCachingPerDirectoryResolution();
11811181
this.program = this.languageService.getProgram(); // TODO: GH#18217
11821182
this.dirty = false;

‎src/testRunner/unittests/tscWatch/watchApi.ts

+74-17
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
namespace ts.tscWatch {
22
describe("unittests:: tsc-watch:: watchAPI:: tsc-watch with custom module resolution", () => {
3-
const configFileJson: any = {
4-
compilerOptions: { module: "commonjs", resolveJsonModule: true },
5-
files: ["index.ts"]
6-
};
7-
const mainFile: File = {
8-
path: `${projectRoot}/index.ts`,
9-
content: "import settings from './settings.json';"
10-
};
11-
const config: File = {
12-
path: `${projectRoot}/tsconfig.json`,
13-
content: JSON.stringify(configFileJson)
14-
};
15-
const settingsJson: File = {
16-
path: `${projectRoot}/settings.json`,
17-
content: JSON.stringify({ content: "Print this" })
18-
};
19-
203
it("verify that module resolution with json extension works when returned without extension", () => {
4+
const configFileJson: any = {
5+
compilerOptions: { module: "commonjs", resolveJsonModule: true },
6+
files: ["index.ts"]
7+
};
8+
const mainFile: File = {
9+
path: `${projectRoot}/index.ts`,
10+
content: "import settings from './settings.json';"
11+
};
12+
const config: File = {
13+
path: `${projectRoot}/tsconfig.json`,
14+
content: JSON.stringify(configFileJson)
15+
};
16+
const settingsJson: File = {
17+
path: `${projectRoot}/settings.json`,
18+
content: JSON.stringify({ content: "Print this" })
19+
};
2120
const { sys, baseline, oldSnap, cb, getPrograms } = createBaseline(createWatchedSystem(
2221
[libFile, mainFile, config, settingsJson],
2322
{ currentDirectory: projectRoot }),
@@ -50,6 +49,64 @@ namespace ts.tscWatch {
5049
watchOrSolution: watch
5150
});
5251
});
52+
53+
describe("hasInvalidatedResolution", () => {
54+
function verifyWatch(subScenario: string, implementHasInvalidatedResolution: boolean) {
55+
it(subScenario, () => {
56+
const { sys, baseline, oldSnap, cb, getPrograms } = createBaseline(createWatchedSystem({
57+
[`${projectRoot}/tsconfig.json`]: JSON.stringify({
58+
compilerOptions: { traceResolution: true, extendedDiagnostics: true },
59+
files: ["main.ts"]
60+
}),
61+
[`${projectRoot}/main.ts`]: `import { foo } from "./other";`,
62+
[`${projectRoot}/other.d.ts`]: "export function foo(): void;",
63+
[libFile.path]: libFile.content,
64+
}, { currentDirectory: projectRoot }));
65+
const host = createWatchCompilerHostOfConfigFileForBaseline({
66+
configFileName: `${projectRoot}/tsconfig.json`,
67+
system: sys,
68+
cb,
69+
});
70+
host.resolveModuleNames = (moduleNames, containingFile, _reusedNames, _redirectedReference, options) =>
71+
moduleNames.map(m => resolveModuleName(m, containingFile, options, host).resolvedModule);
72+
// Invalidate resolutions only when ts file is created
73+
if (implementHasInvalidatedResolution) host.hasInvalidatedResolution = () => sys.fileExists(`${projectRoot}/other.ts`);
74+
const watch = createWatchProgram(host);
75+
runWatchBaseline({
76+
scenario: "watchApi",
77+
subScenario,
78+
commandLineArgs: ["--w"],
79+
sys,
80+
baseline,
81+
oldSnap,
82+
getPrograms,
83+
changes: [
84+
{
85+
caption: "write other with same contents",
86+
change: sys => sys.appendFile(`${projectRoot}/other.d.ts`, ""),
87+
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
88+
},
89+
{
90+
caption: "change other file",
91+
change: sys => sys.appendFile(`${projectRoot}/other.d.ts`, "export function bar(): void;"),
92+
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
93+
},
94+
{
95+
caption: "write other with same contents but write ts file",
96+
change: sys => {
97+
sys.appendFile(`${projectRoot}/other.d.ts`, "");
98+
sys.writeFile(`${projectRoot}/other.ts`, "export function foo() {}");
99+
},
100+
timeouts: sys => sys.runQueuedTimeoutCallbacks(),
101+
},
102+
],
103+
watchOrSolution: watch
104+
});
105+
});
106+
}
107+
verifyWatch("host implements does not implement hasInvalidatedResolution", /*implementHasInvalidatedResolution*/ false);
108+
verifyWatch("host implements hasInvalidatedResolution", /*implementHasInvalidatedResolution*/ true);
109+
});
53110
});
54111

55112
describe("unittests:: tsc-watch:: watchAPI:: tsc-watch expose error count to watch status reporter", () => {

‎tests/baselines/reference/api/tsserverlibrary.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -3320,6 +3320,8 @@ declare namespace ts {
33203320
*/
33213321
resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[];
33223322
getEnvironmentVariable?(name: string): string | undefined;
3323+
/** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */
3324+
hasInvalidatedResolution?(filePath: Path): boolean;
33233325
createHash?(data: string): string;
33243326
getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined;
33253327
}
@@ -5442,6 +5444,8 @@ declare namespace ts {
54425444
resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
54435445
/** If provided, used to resolve type reference directives, otherwise typescript's default resolution */
54445446
resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[];
5447+
/** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */
5448+
hasInvalidatedResolution?(filePath: Path): boolean;
54455449
/**
54465450
* Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it
54475451
*/

‎tests/baselines/reference/api/typescript.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -3320,6 +3320,8 @@ declare namespace ts {
33203320
*/
33213321
resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[];
33223322
getEnvironmentVariable?(name: string): string | undefined;
3323+
/** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */
3324+
hasInvalidatedResolution?(filePath: Path): boolean;
33233325
createHash?(data: string): string;
33243326
getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined;
33253327
}
@@ -5442,6 +5444,8 @@ declare namespace ts {
54425444
resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
54435445
/** If provided, used to resolve type reference directives, otherwise typescript's default resolution */
54445446
resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[];
5447+
/** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */
5448+
hasInvalidatedResolution?(filePath: Path): boolean;
54455449
/**
54465450
* Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it
54475451
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,287 @@
1+
Input::
2+
//// [/user/username/projects/myproject/tsconfig.json]
3+
{"compilerOptions":{"traceResolution":true,"extendedDiagnostics":true},"files":["main.ts"]}
4+
5+
//// [/user/username/projects/myproject/main.ts]
6+
import { foo } from "./other";
7+
8+
//// [/user/username/projects/myproject/other.d.ts]
9+
export function foo(): void;
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+
25+
/a/lib/tsc.js --w
26+
Output::
27+
>> Screen clear
28+
[12:00:23 AM] Starting compilation in watch mode...
29+
30+
Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false
31+
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Config file
32+
Synchronizing program
33+
CreatingProgramWith::
34+
roots: ["/user/username/projects/myproject/main.ts"]
35+
options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
36+
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/main.ts 250 undefined Source file
37+
======== Resolving module './other' from '/user/username/projects/myproject/main.ts'. ========
38+
Module resolution kind is not specified, using 'NodeJs'.
39+
Loading module as file / folder, candidate module location '/user/username/projects/myproject/other', target file type 'TypeScript'.
40+
File '/user/username/projects/myproject/other.ts' does not exist.
41+
File '/user/username/projects/myproject/other.tsx' does not exist.
42+
File '/user/username/projects/myproject/other.d.ts' exist - use it as a name resolution result.
43+
======== Module name './other' was successfully resolved to '/user/username/projects/myproject/other.d.ts'. ========
44+
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file
45+
FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 undefined Source file
46+
DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Type roots
47+
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Type roots
48+
[12:00:26 AM] Found 0 errors. Watching for file changes.
49+
50+
51+
52+
Program root files: ["/user/username/projects/myproject/main.ts"]
53+
Program options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
54+
Program structureReused: Not
55+
Program files::
56+
/a/lib/lib.d.ts
57+
/user/username/projects/myproject/other.d.ts
58+
/user/username/projects/myproject/main.ts
59+
60+
Semantic diagnostics in builder refreshed for::
61+
/a/lib/lib.d.ts
62+
/user/username/projects/myproject/other.d.ts
63+
/user/username/projects/myproject/main.ts
64+
65+
Shape signatures in builder refreshed for::
66+
/a/lib/lib.d.ts (used version)
67+
/user/username/projects/myproject/other.d.ts (used version)
68+
/user/username/projects/myproject/main.ts (used version)
69+
70+
PolledWatches::
71+
/user/username/projects/myproject/node_modules/@types:
72+
{"pollingInterval":500}
73+
74+
FsWatches::
75+
/user/username/projects/myproject/tsconfig.json:
76+
{}
77+
/user/username/projects/myproject/main.ts:
78+
{}
79+
/user/username/projects/myproject/other.d.ts:
80+
{}
81+
/a/lib/lib.d.ts:
82+
{}
83+
84+
FsWatchesRecursive::
85+
86+
exitCode:: ExitStatus.undefined
87+
88+
//// [/user/username/projects/myproject/main.js]
89+
"use strict";
90+
exports.__esModule = true;
91+
92+
93+
94+
Change:: write other with same contents
95+
96+
Input::
97+
//// [/user/username/projects/myproject/other.d.ts] file changed its modified time
98+
99+
Output::
100+
FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file
101+
Scheduling update
102+
Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file
103+
Synchronizing program
104+
[12:00:29 AM] File change detected. Starting incremental compilation...
105+
106+
CreatingProgramWith::
107+
roots: ["/user/username/projects/myproject/main.ts"]
108+
options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
109+
======== Resolving module './other' from '/user/username/projects/myproject/main.ts'. ========
110+
Module resolution kind is not specified, using 'NodeJs'.
111+
Loading module as file / folder, candidate module location '/user/username/projects/myproject/other', target file type 'TypeScript'.
112+
File '/user/username/projects/myproject/other.ts' does not exist.
113+
File '/user/username/projects/myproject/other.tsx' does not exist.
114+
File '/user/username/projects/myproject/other.d.ts' exist - use it as a name resolution result.
115+
======== Module name './other' was successfully resolved to '/user/username/projects/myproject/other.d.ts'. ========
116+
[12:00:30 AM] Found 0 errors. Watching for file changes.
117+
118+
119+
120+
Program root files: ["/user/username/projects/myproject/main.ts"]
121+
Program options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
122+
Program structureReused: SafeModules
123+
Program files::
124+
/a/lib/lib.d.ts
125+
/user/username/projects/myproject/other.d.ts
126+
/user/username/projects/myproject/main.ts
127+
128+
Semantic diagnostics in builder refreshed for::
129+
130+
No shapes updated in the builder::
131+
132+
PolledWatches::
133+
/user/username/projects/myproject/node_modules/@types:
134+
{"pollingInterval":500}
135+
136+
FsWatches::
137+
/user/username/projects/myproject/tsconfig.json:
138+
{}
139+
/user/username/projects/myproject/main.ts:
140+
{}
141+
/user/username/projects/myproject/other.d.ts:
142+
{}
143+
/a/lib/lib.d.ts:
144+
{}
145+
146+
FsWatchesRecursive::
147+
148+
exitCode:: ExitStatus.undefined
149+
150+
151+
Change:: change other file
152+
153+
Input::
154+
//// [/user/username/projects/myproject/other.d.ts]
155+
export function foo(): void;export function bar(): void;
156+
157+
158+
Output::
159+
FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file
160+
Scheduling update
161+
Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file
162+
Synchronizing program
163+
[12:00:33 AM] File change detected. Starting incremental compilation...
164+
165+
CreatingProgramWith::
166+
roots: ["/user/username/projects/myproject/main.ts"]
167+
options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
168+
======== Resolving module './other' from '/user/username/projects/myproject/main.ts'. ========
169+
Module resolution kind is not specified, using 'NodeJs'.
170+
Loading module as file / folder, candidate module location '/user/username/projects/myproject/other', target file type 'TypeScript'.
171+
File '/user/username/projects/myproject/other.ts' does not exist.
172+
File '/user/username/projects/myproject/other.tsx' does not exist.
173+
File '/user/username/projects/myproject/other.d.ts' exist - use it as a name resolution result.
174+
======== Module name './other' was successfully resolved to '/user/username/projects/myproject/other.d.ts'. ========
175+
[12:00:37 AM] Found 0 errors. Watching for file changes.
176+
177+
178+
179+
Program root files: ["/user/username/projects/myproject/main.ts"]
180+
Program options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
181+
Program structureReused: SafeModules
182+
Program files::
183+
/a/lib/lib.d.ts
184+
/user/username/projects/myproject/other.d.ts
185+
/user/username/projects/myproject/main.ts
186+
187+
Semantic diagnostics in builder refreshed for::
188+
/user/username/projects/myproject/other.d.ts
189+
/user/username/projects/myproject/main.ts
190+
191+
Shape signatures in builder refreshed for::
192+
/user/username/projects/myproject/other.d.ts (used version)
193+
/user/username/projects/myproject/main.ts (computed .d.ts)
194+
195+
PolledWatches::
196+
/user/username/projects/myproject/node_modules/@types:
197+
{"pollingInterval":500}
198+
199+
FsWatches::
200+
/user/username/projects/myproject/tsconfig.json:
201+
{}
202+
/user/username/projects/myproject/main.ts:
203+
{}
204+
/user/username/projects/myproject/other.d.ts:
205+
{}
206+
/a/lib/lib.d.ts:
207+
{}
208+
209+
FsWatchesRecursive::
210+
211+
exitCode:: ExitStatus.undefined
212+
213+
//// [/user/username/projects/myproject/main.js] file written with same contents
214+
215+
Change:: write other with same contents but write ts file
216+
217+
Input::
218+
//// [/user/username/projects/myproject/other.d.ts] file changed its modified time
219+
//// [/user/username/projects/myproject/other.ts]
220+
export function foo() {}
221+
222+
223+
Output::
224+
FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file
225+
Scheduling update
226+
Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file
227+
Synchronizing program
228+
[12:00:42 AM] File change detected. Starting incremental compilation...
229+
230+
CreatingProgramWith::
231+
roots: ["/user/username/projects/myproject/main.ts"]
232+
options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
233+
======== Resolving module './other' from '/user/username/projects/myproject/main.ts'. ========
234+
Module resolution kind is not specified, using 'NodeJs'.
235+
Loading module as file / folder, candidate module location '/user/username/projects/myproject/other', target file type 'TypeScript'.
236+
File '/user/username/projects/myproject/other.ts' exist - use it as a name resolution result.
237+
======== Module name './other' was successfully resolved to '/user/username/projects/myproject/other.ts'. ========
238+
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/other.ts 250 undefined Source file
239+
[12:00:48 AM] Found 0 errors. Watching for file changes.
240+
241+
242+
243+
Program root files: ["/user/username/projects/myproject/main.ts"]
244+
Program options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
245+
Program structureReused: SafeModules
246+
Program files::
247+
/a/lib/lib.d.ts
248+
/user/username/projects/myproject/other.ts
249+
/user/username/projects/myproject/main.ts
250+
251+
Semantic diagnostics in builder refreshed for::
252+
/user/username/projects/myproject/other.ts
253+
/user/username/projects/myproject/main.ts
254+
255+
Shape signatures in builder refreshed for::
256+
/user/username/projects/myproject/other.ts (computed .d.ts)
257+
/user/username/projects/myproject/main.ts (computed .d.ts)
258+
259+
PolledWatches::
260+
/user/username/projects/myproject/node_modules/@types:
261+
{"pollingInterval":500}
262+
263+
FsWatches::
264+
/user/username/projects/myproject/tsconfig.json:
265+
{}
266+
/user/username/projects/myproject/main.ts:
267+
{}
268+
/user/username/projects/myproject/other.d.ts:
269+
{}
270+
/a/lib/lib.d.ts:
271+
{}
272+
/user/username/projects/myproject/other.ts:
273+
{}
274+
275+
FsWatchesRecursive::
276+
277+
exitCode:: ExitStatus.undefined
278+
279+
//// [/user/username/projects/myproject/main.js] file written with same contents
280+
//// [/user/username/projects/myproject/other.js]
281+
"use strict";
282+
exports.__esModule = true;
283+
exports.foo = void 0;
284+
function foo() { }
285+
exports.foo = foo;
286+
287+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
1+
Input::
2+
//// [/user/username/projects/myproject/tsconfig.json]
3+
{"compilerOptions":{"traceResolution":true,"extendedDiagnostics":true},"files":["main.ts"]}
4+
5+
//// [/user/username/projects/myproject/main.ts]
6+
import { foo } from "./other";
7+
8+
//// [/user/username/projects/myproject/other.d.ts]
9+
export function foo(): void;
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+
25+
/a/lib/tsc.js --w
26+
Output::
27+
>> Screen clear
28+
[12:00:23 AM] Starting compilation in watch mode...
29+
30+
Current directory: /user/username/projects/myproject CaseSensitiveFileNames: false
31+
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/tsconfig.json 2000 undefined Config file
32+
Synchronizing program
33+
CreatingProgramWith::
34+
roots: ["/user/username/projects/myproject/main.ts"]
35+
options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
36+
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/main.ts 250 undefined Source file
37+
======== Resolving module './other' from '/user/username/projects/myproject/main.ts'. ========
38+
Module resolution kind is not specified, using 'NodeJs'.
39+
Loading module as file / folder, candidate module location '/user/username/projects/myproject/other', target file type 'TypeScript'.
40+
File '/user/username/projects/myproject/other.ts' does not exist.
41+
File '/user/username/projects/myproject/other.tsx' does not exist.
42+
File '/user/username/projects/myproject/other.d.ts' exist - use it as a name resolution result.
43+
======== Module name './other' was successfully resolved to '/user/username/projects/myproject/other.d.ts'. ========
44+
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file
45+
FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 undefined Source file
46+
DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Type roots
47+
Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Type roots
48+
[12:00:26 AM] Found 0 errors. Watching for file changes.
49+
50+
51+
52+
Program root files: ["/user/username/projects/myproject/main.ts"]
53+
Program options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
54+
Program structureReused: Not
55+
Program files::
56+
/a/lib/lib.d.ts
57+
/user/username/projects/myproject/other.d.ts
58+
/user/username/projects/myproject/main.ts
59+
60+
Semantic diagnostics in builder refreshed for::
61+
/a/lib/lib.d.ts
62+
/user/username/projects/myproject/other.d.ts
63+
/user/username/projects/myproject/main.ts
64+
65+
Shape signatures in builder refreshed for::
66+
/a/lib/lib.d.ts (used version)
67+
/user/username/projects/myproject/other.d.ts (used version)
68+
/user/username/projects/myproject/main.ts (used version)
69+
70+
PolledWatches::
71+
/user/username/projects/myproject/node_modules/@types:
72+
{"pollingInterval":500}
73+
74+
FsWatches::
75+
/user/username/projects/myproject/tsconfig.json:
76+
{}
77+
/user/username/projects/myproject/main.ts:
78+
{}
79+
/user/username/projects/myproject/other.d.ts:
80+
{}
81+
/a/lib/lib.d.ts:
82+
{}
83+
84+
FsWatchesRecursive::
85+
86+
exitCode:: ExitStatus.undefined
87+
88+
//// [/user/username/projects/myproject/main.js]
89+
"use strict";
90+
exports.__esModule = true;
91+
92+
93+
94+
Change:: write other with same contents
95+
96+
Input::
97+
//// [/user/username/projects/myproject/other.d.ts] file changed its modified time
98+
99+
Output::
100+
FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file
101+
Scheduling update
102+
Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file
103+
Synchronizing program
104+
[12:00:29 AM] File change detected. Starting incremental compilation...
105+
106+
CreatingProgramWith::
107+
roots: ["/user/username/projects/myproject/main.ts"]
108+
options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
109+
[12:00:30 AM] Found 0 errors. Watching for file changes.
110+
111+
112+
113+
Program root files: ["/user/username/projects/myproject/main.ts"]
114+
Program options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
115+
Program structureReused: Completely
116+
Program files::
117+
/a/lib/lib.d.ts
118+
/user/username/projects/myproject/other.d.ts
119+
/user/username/projects/myproject/main.ts
120+
121+
Semantic diagnostics in builder refreshed for::
122+
123+
No shapes updated in the builder::
124+
125+
PolledWatches::
126+
/user/username/projects/myproject/node_modules/@types:
127+
{"pollingInterval":500}
128+
129+
FsWatches::
130+
/user/username/projects/myproject/tsconfig.json:
131+
{}
132+
/user/username/projects/myproject/main.ts:
133+
{}
134+
/user/username/projects/myproject/other.d.ts:
135+
{}
136+
/a/lib/lib.d.ts:
137+
{}
138+
139+
FsWatchesRecursive::
140+
141+
exitCode:: ExitStatus.undefined
142+
143+
144+
Change:: change other file
145+
146+
Input::
147+
//// [/user/username/projects/myproject/other.d.ts]
148+
export function foo(): void;export function bar(): void;
149+
150+
151+
Output::
152+
FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file
153+
Scheduling update
154+
Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file
155+
Synchronizing program
156+
[12:00:33 AM] File change detected. Starting incremental compilation...
157+
158+
CreatingProgramWith::
159+
roots: ["/user/username/projects/myproject/main.ts"]
160+
options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
161+
[12:00:37 AM] Found 0 errors. Watching for file changes.
162+
163+
164+
165+
Program root files: ["/user/username/projects/myproject/main.ts"]
166+
Program options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
167+
Program structureReused: Completely
168+
Program files::
169+
/a/lib/lib.d.ts
170+
/user/username/projects/myproject/other.d.ts
171+
/user/username/projects/myproject/main.ts
172+
173+
Semantic diagnostics in builder refreshed for::
174+
/user/username/projects/myproject/other.d.ts
175+
/user/username/projects/myproject/main.ts
176+
177+
Shape signatures in builder refreshed for::
178+
/user/username/projects/myproject/other.d.ts (used version)
179+
/user/username/projects/myproject/main.ts (computed .d.ts)
180+
181+
PolledWatches::
182+
/user/username/projects/myproject/node_modules/@types:
183+
{"pollingInterval":500}
184+
185+
FsWatches::
186+
/user/username/projects/myproject/tsconfig.json:
187+
{}
188+
/user/username/projects/myproject/main.ts:
189+
{}
190+
/user/username/projects/myproject/other.d.ts:
191+
{}
192+
/a/lib/lib.d.ts:
193+
{}
194+
195+
FsWatchesRecursive::
196+
197+
exitCode:: ExitStatus.undefined
198+
199+
//// [/user/username/projects/myproject/main.js] file written with same contents
200+
201+
Change:: write other with same contents but write ts file
202+
203+
Input::
204+
//// [/user/username/projects/myproject/other.d.ts] file changed its modified time
205+
//// [/user/username/projects/myproject/other.ts]
206+
export function foo() {}
207+
208+
209+
Output::
210+
FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file
211+
Scheduling update
212+
Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file
213+
Synchronizing program
214+
[12:00:42 AM] File change detected. Starting incremental compilation...
215+
216+
CreatingProgramWith::
217+
roots: ["/user/username/projects/myproject/main.ts"]
218+
options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
219+
======== Resolving module './other' from '/user/username/projects/myproject/main.ts'. ========
220+
Module resolution kind is not specified, using 'NodeJs'.
221+
Loading module as file / folder, candidate module location '/user/username/projects/myproject/other', target file type 'TypeScript'.
222+
File '/user/username/projects/myproject/other.ts' exist - use it as a name resolution result.
223+
======== Module name './other' was successfully resolved to '/user/username/projects/myproject/other.ts'. ========
224+
FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/other.ts 250 undefined Source file
225+
[12:00:48 AM] Found 0 errors. Watching for file changes.
226+
227+
228+
229+
Program root files: ["/user/username/projects/myproject/main.ts"]
230+
Program options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"}
231+
Program structureReused: SafeModules
232+
Program files::
233+
/a/lib/lib.d.ts
234+
/user/username/projects/myproject/other.ts
235+
/user/username/projects/myproject/main.ts
236+
237+
Semantic diagnostics in builder refreshed for::
238+
/user/username/projects/myproject/other.ts
239+
/user/username/projects/myproject/main.ts
240+
241+
Shape signatures in builder refreshed for::
242+
/user/username/projects/myproject/other.ts (computed .d.ts)
243+
/user/username/projects/myproject/main.ts (computed .d.ts)
244+
245+
PolledWatches::
246+
/user/username/projects/myproject/node_modules/@types:
247+
{"pollingInterval":500}
248+
249+
FsWatches::
250+
/user/username/projects/myproject/tsconfig.json:
251+
{}
252+
/user/username/projects/myproject/main.ts:
253+
{}
254+
/user/username/projects/myproject/other.d.ts:
255+
{}
256+
/a/lib/lib.d.ts:
257+
{}
258+
/user/username/projects/myproject/other.ts:
259+
{}
260+
261+
FsWatchesRecursive::
262+
263+
exitCode:: ExitStatus.undefined
264+
265+
//// [/user/username/projects/myproject/main.js] file written with same contents
266+
//// [/user/username/projects/myproject/other.js]
267+
"use strict";
268+
exports.__esModule = true;
269+
exports.foo = void 0;
270+
function foo() { }
271+
exports.foo = foo;
272+
273+

0 commit comments

Comments
 (0)
Please sign in to comment.