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 { export function isWeb(): boolean {
return typeof process !== 'undefined'; return typeof process === 'undefined';
} }

View file

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