提交 e3294dc7 编写于 作者: M Matt Bierner

Fix exception if extension is not installed

上级 1151dab2
......@@ -155,11 +155,13 @@ export class TypeScriptVersionProvider {
private getContributedVersion(extensionId: string, pathToTs: readonly string[]): TypeScriptVersion | undefined {
try {
const { extensionPath } = vscode.extensions.getExtension(extensionId)!;
const typescriptPath = path.join(extensionPath, ...pathToTs, 'typescript', 'lib');
const bundledVersion = new TypeScriptVersion(typescriptPath, '');
if (bundledVersion.isValid) {
return bundledVersion;
const extension = vscode.extensions.getExtension(extensionId);
if (extension) {
const typescriptPath = path.join(extension.extensionPath, ...pathToTs, 'typescript', 'lib');
const bundledVersion = new TypeScriptVersion(typescriptPath, '');
if (bundledVersion.isValid) {
return bundledVersion;
}
}
} catch {
// noop
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册