mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-20 22:51:17 -05:00
Fix missing file name of extended source file in synchronizeProjectList when it is missing on disk (#41222)
Fixes #40136
This commit is contained in:
@@ -1578,7 +1578,7 @@ namespace ts {
|
||||
*/
|
||||
export function readJsonConfigFile(fileName: string, readFile: (path: string) => string | undefined): TsConfigSourceFile {
|
||||
const textOrDiagnostic = tryReadFile(fileName, readFile);
|
||||
return isString(textOrDiagnostic) ? parseJsonText(fileName, textOrDiagnostic) : <TsConfigSourceFile>{ parseDiagnostics: [textOrDiagnostic] };
|
||||
return isString(textOrDiagnostic) ? parseJsonText(fileName, textOrDiagnostic) : <TsConfigSourceFile>{ fileName, parseDiagnostics: [textOrDiagnostic] };
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
|
||||
@@ -1481,6 +1481,48 @@ namespace ts.projectSystem {
|
||||
]);
|
||||
});
|
||||
|
||||
it("synchronizeProjectList returns correct information when base configuration file cannot be resolved", () => {
|
||||
const file: File = {
|
||||
path: `${tscWatch.projectRoot}/index.ts`,
|
||||
content: "export const foo = 5;"
|
||||
};
|
||||
const config: File = {
|
||||
path: `${tscWatch.projectRoot}/tsconfig.json`,
|
||||
content: JSON.stringify({ extends: "./tsconfig_base.json" })
|
||||
};
|
||||
const host = createServerHost([file, config, libFile]);
|
||||
const projectService = createProjectService(host);
|
||||
projectService.openClientFile(file.path);
|
||||
const knownProjects = projectService.synchronizeProjectList([], /*includeProjectReferenceRedirectInfo*/ false);
|
||||
assert.deepEqual(knownProjects[0].files, [
|
||||
libFile.path,
|
||||
file.path,
|
||||
config.path,
|
||||
`${tscWatch.projectRoot}/tsconfig_base.json`,
|
||||
]);
|
||||
});
|
||||
|
||||
it("synchronizeProjectList returns correct information when base configuration file cannot be resolved and redirect info is requested", () => {
|
||||
const file: File = {
|
||||
path: `${tscWatch.projectRoot}/index.ts`,
|
||||
content: "export const foo = 5;"
|
||||
};
|
||||
const config: File = {
|
||||
path: `${tscWatch.projectRoot}/tsconfig.json`,
|
||||
content: JSON.stringify({ extends: "./tsconfig_base.json" })
|
||||
};
|
||||
const host = createServerHost([file, config, libFile]);
|
||||
const projectService = createProjectService(host);
|
||||
projectService.openClientFile(file.path);
|
||||
const knownProjects = projectService.synchronizeProjectList([], /*includeProjectReferenceRedirectInfo*/ true);
|
||||
assert.deepEqual(knownProjects[0].files, [
|
||||
{ fileName: libFile.path, isSourceOfProjectReferenceRedirect: false },
|
||||
{ fileName: file.path, isSourceOfProjectReferenceRedirect: false },
|
||||
{ fileName: config.path, isSourceOfProjectReferenceRedirect: false },
|
||||
{ fileName: `${tscWatch.projectRoot}/tsconfig_base.json`, isSourceOfProjectReferenceRedirect: false },
|
||||
]);
|
||||
});
|
||||
|
||||
it("handles delayed directory watch invoke on file creation", () => {
|
||||
const projectRootPath = "/users/username/projects/project";
|
||||
const fileB: File = {
|
||||
|
||||
Reference in New Issue
Block a user