handle the case when conversion of tsconfig.json failed (#14160)

This commit is contained in:
Vladimir Matveev 2017-02-21 10:27:50 -08:00 committed by GitHub
parent b4d2b1db0d
commit dca368b719
2 changed files with 29 additions and 2 deletions

View file

@ -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", () => {

View file

@ -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,