Fixing some errors when loading workspace TS versions

This commit is contained in:
Matt Bierner 2020-07-21 16:41:02 -07:00
parent 23c4467ed3
commit ae7254a2e9
2 changed files with 11 additions and 9 deletions

View file

@ -4,5 +4,5 @@
*--------------------------------------------------------------------------------------------*/
export function isWeb(): boolean {
return typeof process !== 'undefined';
return typeof process === 'undefined';
}

View file

@ -82,8 +82,8 @@ export class DiskTypeScriptVersionProvider implements ITypeScriptVersionProvider
try {
const extension = vscode.extensions.getExtension(extensionId);
if (extension) {
const typescriptPath = path.join(extension.extensionPath, ...pathToTs, 'typescript', 'lib');
const bundledVersion = new TypeScriptVersion(source, path.join(typescriptPath, 'tsserver.js'), DiskTypeScriptVersionProvider.getApiVersion(typescriptPath), '');
const serverPath = path.join(extension.extensionPath, ...pathToTs, 'typescript', 'lib', 'tsserver.js');
const bundledVersion = new TypeScriptVersion(source, serverPath, DiskTypeScriptVersionProvider.getApiVersion(serverPath), '');
if (bundledVersion.isValid) {
return bundledVersion;
}
@ -101,19 +101,21 @@ export class DiskTypeScriptVersionProvider implements ITypeScriptVersionProvider
private loadVersionsFromSetting(source: TypeScriptVersionSource, tsdkPathSetting: string): TypeScriptVersion[] {
if (path.isAbsolute(tsdkPathSetting)) {
const serverPath = path.join(tsdkPathSetting, 'tsserver.js');
return [
new TypeScriptVersion(source,
path.join(tsdkPathSetting, 'tsserver.js'),
DiskTypeScriptVersionProvider.getApiVersion(tsdkPathSetting))
serverPath,
DiskTypeScriptVersionProvider.getApiVersion(serverPath))
];
}
const workspacePath = RelativeWorkspacePathResolver.asAbsoluteWorkspacePath(tsdkPathSetting);
if (workspacePath !== undefined) {
const serverPath = path.join(workspacePath, 'tsserver.js');
return [
new TypeScriptVersion(source,
path.join(workspacePath, 'tsserver.js'),
DiskTypeScriptVersionProvider.getApiVersion(tsdkPathSetting),
serverPath,
DiskTypeScriptVersionProvider.getApiVersion(serverPath),
tsdkPathSetting)
];
}
@ -138,8 +140,8 @@ export class DiskTypeScriptVersionProvider implements ITypeScriptVersionProvider
label = path.join(root.name, relativePath);
}
const serverPath = path.join(root.uri.fsPath, relativePath);
versions.push(new TypeScriptVersion(source, path.join(serverPath, 'tsserver.js'), DiskTypeScriptVersionProvider.getApiVersion(serverPath), label));
const serverPath = path.join(root.uri.fsPath, relativePath, 'tsserver.js');
versions.push(new TypeScriptVersion(source, serverPath, DiskTypeScriptVersionProvider.getApiVersion(serverPath), label));
}
return versions;
}