Fix exception if extension is not installed

This commit is contained in:
Matt Bierner
2019-06-13 19:59:36 -07:00
parent 1151dab2bf
commit e3294dc7b1

View File

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