mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-11 06:02:53 -05:00
handle the case when conversion of tsconfig.json failed (#14160)
This commit is contained in:
committed by
Arthur Ozga
parent
bb86e9e291
commit
a2f61a8041
@@ -3035,6 +3035,33 @@ namespace ts.projectSystem {
|
||||
const inferredProject = projectService.inferredProjects[0];
|
||||
assert.isTrue(inferredProject.containsFile(<server.NormalizedPath>file1.path));
|
||||
});
|
||||
|
||||
it("should be able to handle @types if input file list is empty", () => {
|
||||
const f = {
|
||||
path: "/a/app.ts",
|
||||
content: "let x = 1"
|
||||
};
|
||||
const config = {
|
||||
path: "/a/tsconfig.json",
|
||||
content: JSON.stringify({
|
||||
compiler: {},
|
||||
files: []
|
||||
})
|
||||
};
|
||||
const t1 = {
|
||||
path: "/a/node_modules/@types/typings/index.d.ts",
|
||||
content: `export * from "./lib"`
|
||||
};
|
||||
const t2 = {
|
||||
path: "/a/node_modules/@types/typings/lib.d.ts",
|
||||
content: `export const x: number`
|
||||
};
|
||||
const host = createServerHost([f, config, t1, t2], { currentDirectory: getDirectoryPath(f.path) });
|
||||
const projectService = createProjectService(host);
|
||||
|
||||
projectService.openClientFile(f.path);
|
||||
projectService.checkNumberOfProjects({ configuredProjects: 1, inferredProjects: 1 });
|
||||
});
|
||||
});
|
||||
|
||||
describe("reload", () => {
|
||||
|
||||
@@ -948,9 +948,9 @@ namespace ts.server {
|
||||
|
||||
private openConfigFile(configFileName: NormalizedPath, clientFileName?: string): OpenConfigFileResult {
|
||||
const conversionResult = this.convertConfigFileContentToProjectOptions(configFileName);
|
||||
const projectOptions = conversionResult.success
|
||||
const projectOptions: ProjectOptions = conversionResult.success
|
||||
? conversionResult.projectOptions
|
||||
: { files: [], compilerOptions: {} };
|
||||
: { files: [], compilerOptions: {}, typeAcquisition: { enable: false } };
|
||||
const project = this.createAndAddConfiguredProject(configFileName, projectOptions, conversionResult.configFileErrors, clientFileName);
|
||||
return {
|
||||
success: conversionResult.success,
|
||||
|
||||
Reference in New Issue
Block a user