@@ -9,8 +9,8 @@ import * as nls from 'vscode-nls';
9
9
import API from './api' ;
10
10
import { TypeScriptServiceConfiguration } from './configuration' ;
11
11
import { RelativeWorkspacePathResolver } from './relativePathResolver' ;
12
- const localize = nls . loadMessageBundle ( ) ;
13
12
13
+ const localize = nls . loadMessageBundle ( ) ;
14
14
15
15
export class TypeScriptVersion {
16
16
constructor (
@@ -109,7 +109,7 @@ export class TypeScriptVersionProvider {
109
109
return globals [ 0 ] ;
110
110
}
111
111
}
112
- return undefined ;
112
+ return this . contributedTsNextVersion ;
113
113
}
114
114
115
115
public get localVersion ( ) : TypeScriptVersion | undefined {
@@ -138,20 +138,33 @@ export class TypeScriptVersionProvider {
138
138
}
139
139
140
140
public get bundledVersion ( ) : TypeScriptVersion {
141
+ const version = this . getContributedVersion ( 'vscode.typescript-language-features' , [ '..' , 'node_modules' ] ) ;
142
+ if ( version ) {
143
+ return version ;
144
+ }
145
+
146
+ vscode . window . showErrorMessage ( localize (
147
+ 'noBundledServerFound' ,
148
+ 'VS Code\'s tsserver was deleted by another application such as a misbehaving virus detection tool. Please reinstall VS Code.' ) ) ;
149
+ throw new Error ( 'Could not find bundled tsserver.js' ) ;
150
+ }
151
+
152
+ private get contributedTsNextVersion ( ) : TypeScriptVersion | undefined {
153
+ return this . getContributedVersion ( 'ms-vscode.vscode-typescript-next' , [ 'node_modules' ] ) ;
154
+ }
155
+
156
+ private getContributedVersion ( extensionId : string , pathToTs : readonly string [ ] ) : TypeScriptVersion | undefined {
141
157
try {
142
- const { extensionPath } = vscode . extensions . getExtension ( 'vscode.typescript-language-features' ) ! ;
143
- const typescriptPath = path . join ( extensionPath , '../node_modules/ typescript/ lib') ;
158
+ const { extensionPath } = vscode . extensions . getExtension ( extensionId ) ! ;
159
+ const typescriptPath = path . join ( extensionPath , ... pathToTs , ' typescript' , ' lib') ;
144
160
const bundledVersion = new TypeScriptVersion ( typescriptPath , '' ) ;
145
161
if ( bundledVersion . isValid ) {
146
162
return bundledVersion ;
147
163
}
148
- } catch ( e ) {
164
+ } catch {
149
165
// noop
150
166
}
151
- vscode . window . showErrorMessage ( localize (
152
- 'noBundledServerFound' ,
153
- 'VS Code\'s tsserver was deleted by another application such as a misbehaving virus detection tool. Please reinstall VS Code.' ) ) ;
154
- throw new Error ( 'Could not find bundled tsserver.js' ) ;
167
+ return undefined ;
155
168
}
156
169
157
170
private get localTsdkVersions ( ) : TypeScriptVersion [ ] {
0 commit comments