Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't reuse program structure if we errored on filenames differing by case #58299

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/compiler/program.ts
Expand Up @@ -1578,6 +1578,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
let resolvedTypeReferenceDirectiveNames: Map<Path, ModeAwareCache<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>> | undefined;
let resolvedTypeReferenceDirectiveNamesProcessing: Map<Path, readonly ResolvedTypeReferenceDirectiveWithFailedLookupLocations[]> | undefined;

let hasFileNamesDifferOnlyInCasingError = false;

let packageMap: Map<string, boolean> | undefined;

// The below settings are to track if a .js file should be add to the program if loaded via searching under node_modules.
Expand Down Expand Up @@ -1984,6 +1986,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
getFileIncludeReasons: () => fileReasons,
structureIsReused,
writeFile,
hasFileNamesDifferOnlyInCasingError: () => hasFileNamesDifferOnlyInCasingError,
};

onProgramCreateComplete();
Expand Down Expand Up @@ -2424,6 +2427,10 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
return StructureIsReused.Not;
}

if (oldProgram.hasFileNamesDifferOnlyInCasingError()) {
return StructureIsReused.Not;
}

// check properties that can affect structure of the program or module resolution strategy
// if any of these properties has changed - structure cannot be reused
const oldOptions = oldProgram.getCompilerOptions();
Expand Down Expand Up @@ -3584,6 +3591,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
}

function reportFileNamesDifferOnlyInCasingError(fileName: string, existingFile: SourceFile, reason: FileIncludeReason): void {
hasFileNamesDifferOnlyInCasingError = true;
const hasExistingReasonToReportErrorOn = !isReferencedFile(reason) && some(fileReasons.get(existingFile.path), isReferencedFile);
if (hasExistingReasonToReportErrorOn) {
addFilePreprocessingFileExplainingDiagnostic(existingFile, reason, Diagnostics.Already_included_file_name_0_differs_from_file_name_1_only_in_casing, [existingFile.fileName, fileName]);
Expand Down
1 change: 1 addition & 0 deletions src/compiler/types.ts
Expand Up @@ -4888,6 +4888,7 @@ export interface Program extends ScriptReferenceHost {
* @internal
*/
writeFile: WriteFileCallback;
/** @internal */ hasFileNamesDifferOnlyInCasingError(): boolean;
}

/** @internal */
Expand Down
Expand Up @@ -303,7 +303,7 @@ Program options: {
"extendedDiagnostics": true,
"configFilePath": "/user/username/projects/myproject/tsconfig.json"
}
Program structureReused: Completely
Program structureReused: Not
Program files::
/a/lib/lib.d.ts
/user/username/projects/myproject/xY/a.ts
Expand Down
Expand Up @@ -256,7 +256,7 @@ Program options: {
"extendedDiagnostics": true,
"configFilePath": "/user/username/projects/myproject/tsconfig.json"
}
Program structureReused: Completely
Program structureReused: Not
Program files::
/a/lib/lib.d.ts
/user/username/projects/myproject/XY.ts
Expand Down
Expand Up @@ -303,7 +303,7 @@ Program options: {
"extendedDiagnostics": true,
"configFilePath": "/user/username/projects/myproject/tsconfig.json"
}
Program structureReused: Completely
Program structureReused: Not
Program files::
/a/lib/lib.d.ts
/user/username/projects/myproject/Xy/a.ts
Expand Down
Expand Up @@ -256,7 +256,7 @@ Program options: {
"extendedDiagnostics": true,
"configFilePath": "/user/username/projects/myproject/tsconfig.json"
}
Program structureReused: Completely
Program structureReused: Not
Program files::
/a/lib/lib.d.ts
/user/username/projects/myproject/XY.ts
Expand Down
Expand Up @@ -303,7 +303,7 @@ Program options: {
"extendedDiagnostics": true,
"configFilePath": "/user/username/projects/myproject/tsconfig.json"
}
Program structureReused: Completely
Program structureReused: Not
Program files::
/a/lib/lib.d.ts
/user/username/projects/myproject/Xy/a.ts
Expand Down
Expand Up @@ -256,7 +256,7 @@ Program options: {
"extendedDiagnostics": true,
"configFilePath": "/user/username/projects/myproject/tsconfig.json"
}
Program structureReused: Completely
Program structureReused: Not
Program files::
/a/lib/lib.d.ts
/user/username/projects/myproject/XY.ts
Expand Down
Expand Up @@ -230,7 +230,7 @@ Program options: {
"explainFiles": true,
"configFilePath": "/user/username/projects/myproject/tsconfig.json"
}
Program structureReused: Completely
Program structureReused: Not
Program files::
/a/lib/lib.d.ts
/user/username/projects/myproject/ModuleC.ts
Expand Down
Expand Up @@ -474,7 +474,7 @@ Before running Timeout callback:: count: 3

Invoking Timeout callback:: timeoutId:: 4:: checkOne
Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: false structureIsReused:: Completely Elapsed:: *ms
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms
Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured)
Info seq [hh:mm:ss:mss] Files (4)
/a/lib/lib.d.ts Text-1 "/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }"
Expand All @@ -501,7 +501,7 @@ Immedidate callback:: count: 1
Projects::
/user/username/projects/myproject/tsconfig.json (Configured) *changed*
projectStateVersion: 2
projectProgramVersion: 1
projectProgramVersion: 2 *changed*
dirty: false *changed*

ScriptInfos::
Expand Down
Expand Up @@ -551,7 +551,7 @@ Before running Timeout callback:: count: 1
2: checkOne

Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: false structureIsReused:: Completely Elapsed:: *ms
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms
Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured)
Info seq [hh:mm:ss:mss] Files (4)
/a/lib/lib.d.ts Text-1 "/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }"
Expand All @@ -578,7 +578,7 @@ Immedidate callback:: count: 1
Projects::
/user/username/projects/myproject/tsconfig.json (Configured) *changed*
projectStateVersion: 2
projectProgramVersion: 1
projectProgramVersion: 2 *changed*
dirty: false *changed*

Before running Immedidate callback:: count: 1
Expand Down
Expand Up @@ -476,7 +476,7 @@ Before running Timeout callback:: count: 1
2: checkOne

Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: false structureIsReused:: Completely Elapsed:: *ms
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms
Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured)
Info seq [hh:mm:ss:mss] Files (4)
/a/lib/lib.d.ts Text-1 "/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }"
Expand All @@ -503,7 +503,7 @@ Immedidate callback:: count: 1
Projects::
/user/username/projects/myproject/tsconfig.json (Configured) *changed*
projectStateVersion: 2
projectProgramVersion: 1
projectProgramVersion: 2 *changed*
dirty: false *changed*

Before running Immedidate callback:: count: 1
Expand Down
Expand Up @@ -404,7 +404,7 @@ Before running Timeout callback:: count: 3

Invoking Timeout callback:: timeoutId:: 6:: checkOne
Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: false structureIsReused:: Completely Elapsed:: *ms
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms
Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured)
Info seq [hh:mm:ss:mss] Files (4)
/a/lib/lib.d.ts Text-1 "/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }"
Expand All @@ -431,7 +431,7 @@ Immedidate callback:: count: 1
Projects::
/user/username/projects/myproject/tsconfig.json (Configured) *changed*
projectStateVersion: 2
projectProgramVersion: 1
projectProgramVersion: 2 *changed*
dirty: false *changed*

ScriptInfos::
Expand Down
Expand Up @@ -465,7 +465,7 @@ Before running Timeout callback:: count: 3

Invoking Timeout callback:: timeoutId:: 4:: checkOne
Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: false structureIsReused:: Completely Elapsed:: *ms
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms
Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured)
Info seq [hh:mm:ss:mss] Files (4)
/a/lib/lib.d.ts Text-1 "/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }"
Expand All @@ -492,7 +492,7 @@ Immedidate callback:: count: 1
Projects::
/user/username/projects/myproject/tsconfig.json (Configured) *changed*
projectStateVersion: 2
projectProgramVersion: 1
projectProgramVersion: 2 *changed*
dirty: false *changed*

ScriptInfos::
Expand Down
Expand Up @@ -540,7 +540,7 @@ Before running Timeout callback:: count: 1
2: checkOne

Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: false structureIsReused:: Completely Elapsed:: *ms
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms
Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured)
Info seq [hh:mm:ss:mss] Files (4)
/a/lib/lib.d.ts Text-1 "/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }"
Expand All @@ -567,7 +567,7 @@ Immedidate callback:: count: 1
Projects::
/user/username/projects/myproject/tsconfig.json (Configured) *changed*
projectStateVersion: 2
projectProgramVersion: 1
projectProgramVersion: 2 *changed*
dirty: false *changed*

Before running Immedidate callback:: count: 1
Expand Down
Expand Up @@ -467,7 +467,7 @@ Before running Timeout callback:: count: 1
2: checkOne

Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: false structureIsReused:: Completely Elapsed:: *ms
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms
Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured)
Info seq [hh:mm:ss:mss] Files (4)
/a/lib/lib.d.ts Text-1 "/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }"
Expand All @@ -494,7 +494,7 @@ Immedidate callback:: count: 1
Projects::
/user/username/projects/myproject/tsconfig.json (Configured) *changed*
projectStateVersion: 2
projectProgramVersion: 1
projectProgramVersion: 2 *changed*
dirty: false *changed*

Before running Immedidate callback:: count: 1
Expand Down
Expand Up @@ -397,7 +397,7 @@ Before running Timeout callback:: count: 3

Invoking Timeout callback:: timeoutId:: 6:: checkOne
Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: false structureIsReused:: Completely Elapsed:: *ms
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms
Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured)
Info seq [hh:mm:ss:mss] Files (4)
/a/lib/lib.d.ts Text-1 "/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }"
Expand All @@ -424,7 +424,7 @@ Immedidate callback:: count: 1
Projects::
/user/username/projects/myproject/tsconfig.json (Configured) *changed*
projectStateVersion: 2
projectProgramVersion: 1
projectProgramVersion: 2 *changed*
dirty: false *changed*

ScriptInfos::
Expand Down
Expand Up @@ -474,7 +474,7 @@ Before running Timeout callback:: count: 3

Invoking Timeout callback:: timeoutId:: 4:: checkOne
Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: false structureIsReused:: Completely Elapsed:: *ms
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms
Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured)
Info seq [hh:mm:ss:mss] Files (4)
/a/lib/lib.d.ts Text-1 "/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }"
Expand All @@ -501,7 +501,7 @@ Immedidate callback:: count: 1
Projects::
/user/username/projects/myproject/tsconfig.json (Configured) *changed*
projectStateVersion: 2
projectProgramVersion: 1
projectProgramVersion: 2 *changed*
dirty: false *changed*

ScriptInfos::
Expand Down
Expand Up @@ -551,7 +551,7 @@ Before running Timeout callback:: count: 1
2: checkOne

Info seq [hh:mm:ss:mss] Starting updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: false structureIsReused:: Completely Elapsed:: *ms
Info seq [hh:mm:ss:mss] Finishing updateGraphWorker: Project: /user/username/projects/myproject/tsconfig.json projectStateVersion: 2 projectProgramVersion: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms
Info seq [hh:mm:ss:mss] Project '/user/username/projects/myproject/tsconfig.json' (Configured)
Info seq [hh:mm:ss:mss] Files (4)
/a/lib/lib.d.ts Text-1 "/// <reference no-default-lib=\"true\"/>\ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array<T> { length: number; [n: number]: T; }"
Expand All @@ -578,7 +578,7 @@ Immedidate callback:: count: 1
Projects::
/user/username/projects/myproject/tsconfig.json (Configured) *changed*
projectStateVersion: 2
projectProgramVersion: 1
projectProgramVersion: 2 *changed*
dirty: false *changed*

Before running Immedidate callback:: count: 1
Expand Down