Skip to content

Commit

Permalink
fix: add fault tolerance for invalid reference project path in tsconfig
Browse files Browse the repository at this point in the history
close #1957
  • Loading branch information
johnsoncodehk committed Oct 18, 2022
1 parent b4ea520 commit 1444a23
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions vue-language-tools/vue-language-core/src/utils/ts.ts
Expand Up @@ -27,15 +27,25 @@ export function createParsedCommandLine(
extraFileExtensions: ts.FileExtensionInfo[],
extendsSet = new Set<string>(),
): ParsedCommandLine {
try {
const config = ts.readJsonConfigFile(tsConfigPath, parseConfigHost.readFile);
const content = ts.parseJsonSourceFileConfigFileContent(config, parseConfigHost, path.dirname(tsConfigPath), {}, tsConfigPath, undefined, extraFileExtensions);
// fix https://github.com/johnsoncodehk/volar/issues/1786
// https://github.com/microsoft/TypeScript/issues/30457
// patching ts server broke with outDir + rootDir + composite/incremental
content.options.outDir = undefined;

const config = ts.readJsonConfigFile(tsConfigPath, parseConfigHost.readFile);
const content = ts.parseJsonSourceFileConfigFileContent(config, parseConfigHost, path.dirname(tsConfigPath), {}, tsConfigPath, undefined, extraFileExtensions);
// fix https://github.com/johnsoncodehk/volar/issues/1786
// https://github.com/microsoft/TypeScript/issues/30457
// patching ts server broke with outDir + rootDir + composite/incremental
content.options.outDir = undefined;

return createParsedCommandLineBase(ts, parseConfigHost, content, tsConfigPath, extraFileExtensions, extendsSet);
return createParsedCommandLineBase(ts, parseConfigHost, content, tsConfigPath, extraFileExtensions, extendsSet);
}
catch (err) {
console.log('Failed to resolve tsconfig path:', tsConfigPath);
return {
fileNames: [],
options: {},
vueOptions: {},
errors: [],
};
}
}

function createParsedCommandLineBase(
Expand Down

0 comments on commit 1444a23

Please sign in to comment.