@@ -77,23 +77,6 @@ interface MyMessageItem extends MessageItem {
7777 id : MessageAction ;
7878}
7979
80-
81- function openUrl ( url : string ) {
82- let cmd : string ;
83- switch ( process . platform ) {
84- case 'darwin' :
85- cmd = 'open' ;
86- break ;
87- case 'win32' :
88- cmd = 'start' ;
89- break ;
90- default :
91- cmd = 'xdg-open' ;
92- }
93- return cp . exec ( cmd + ' ' + url ) ;
94- }
95-
96-
9780export default class TypeScriptServiceClient implements ITypescriptServiceClient {
9881
9982 private host : ITypescriptServiceClientHost ;
@@ -103,6 +86,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
10386
10487 private _onReady : { promise : Promise < void > ; resolve : ( ) => void ; reject : ( ) => void ; } ;
10588 private tsdk : string ;
89+ private _checkGlobalTSCVersion : boolean ;
10690 private _experimentalAutoBuild : boolean ;
10791 private trace : Trace ;
10892 private _output : OutputChannel ;
@@ -148,6 +132,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
148132 this . tsdk = configuration . get < string > ( 'typescript.tsdk' , null ) ;
149133 this . _experimentalAutoBuild = false ; // configuration.get<boolean>('typescript.tsserver.experimentalAutoBuild', false);
150134 this . _apiVersion = new API ( '1.0.0' ) ;
135+ this . _checkGlobalTSCVersion = true ;
151136 this . trace = this . readTrace ( ) ;
152137 workspace . onDidChangeConfiguration ( ( ) => {
153138 this . trace = this . readTrace ( ) ;
@@ -182,6 +167,10 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
182167 return this . _experimentalAutoBuild ;
183168 }
184169
170+ public get checkGlobalTSCVersion ( ) : boolean {
171+ return this . _checkGlobalTSCVersion ;
172+ }
173+
185174 public get apiVersion ( ) : API {
186175 return this . _apiVersion ;
187176 }
@@ -280,11 +269,10 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
280269
281270 private startService ( resendModels : boolean = false ) : void {
282271 let modulePath = path . join ( __dirname , '..' , 'node_modules' , 'typescript' , 'lib' , 'tsserver.js' ) ;
283- let checkGlobalVersion = true ;
284272 let showVersionStatusItem = false ;
285273
286274 if ( this . tsdk ) {
287- checkGlobalVersion = false ;
275+ this . _checkGlobalTSCVersion = false ;
288276 if ( ( < any > path ) . isAbsolute ( this . tsdk ) ) {
289277 modulePath = path . join ( this . tsdk , 'tsserver.js' ) ;
290278 } else if ( workspace . rootPath ) {
@@ -306,7 +294,7 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
306294 let localVersion = this . getTypeScriptVersion ( localModulePath ) ;
307295 let shippedVersion = this . getTypeScriptVersion ( modulePath ) ;
308296 if ( localVersion && localVersion !== shippedVersion ) {
309- checkGlobalVersion = false ;
297+ this . _checkGlobalTSCVersion = false ;
310298 versionCheckPromise = window . showInformationMessage < MyMessageItem > (
311299 localize (
312300 'localTSFound' ,
@@ -385,58 +373,15 @@ export default class TypeScriptServiceClient implements ITypescriptServiceClient
385373 VersionStatus . enable ( ! ! this . tsdk || showVersionStatusItem ) ;
386374 VersionStatus . setInfo ( label , tooltip ) ;
387375
376+ // This is backwards compatibility code to move the setting from the local
377+ // store into the workspace setting file.
388378 const doGlobalVersionCheckKey : string = 'doGlobalVersionCheck' ;
389379 const globalStateValue = this . globalState . get ( doGlobalVersionCheckKey , true ) ;
390380 const checkTscVersion = 'check.tscVersion' ;
391381 if ( ! globalStateValue ) {
392382 tsConfig . update ( checkTscVersion , false , true ) ;
393383 this . globalState . update ( doGlobalVersionCheckKey , true ) ;
394384 }
395- if ( checkGlobalVersion && tsConfig . get ( checkTscVersion ) ) {
396- let tscVersion : string = undefined ;
397- try {
398- let out = cp . execSync ( 'tsc --version' , { encoding : 'utf8' } ) ;
399- if ( out ) {
400- let matches = out . trim ( ) . match ( / V e r s i o n \s * ( .* ) $ / ) ;
401- if ( matches && matches . length === 2 ) {
402- tscVersion = matches [ 1 ] ;
403- }
404- }
405- } catch ( error ) {
406- }
407- if ( tscVersion && tscVersion !== version ) {
408- window . showInformationMessage < MyMessageItem > (
409- localize ( 'versionMismatch' , 'Version mismatch! global tsc ({0}) != VS Code\'s language service ({1}). Inconsistent compile errors might occur' , tscVersion , version ) ,
410- {
411- title : localize ( 'moreInformation' , 'More Information' ) ,
412- id : 1
413- } ,
414- {
415- title : localize ( 'doNotCheckAgain' , 'Don\'t Check Again' ) ,
416- id : 2
417- } ,
418- {
419- title : localize ( 'close' , 'Close' ) ,
420- id : 3 ,
421- isCloseAffordance : true
422- }
423- ) . then ( ( selected ) => {
424- if ( ! selected || selected . id === 3 ) {
425- return ;
426- }
427- switch ( selected . id ) {
428- case 1 :
429- openUrl ( 'http://go.microsoft.com/fwlink/?LinkId=826239' ) ;
430- break ;
431- case 2 :
432- tsConfig . update ( checkTscVersion , false , true ) ;
433- window . showInformationMessage ( localize ( 'updateTscCheck' , 'Updated user setting \'typescript.check.tscVersion\' to false' ) ) ;
434- this . globalState . update ( doGlobalVersionCheckKey , false ) ;
435- break ;
436- }
437- } ) ;
438- }
439- }
440385
441386 try {
442387 let options : electron . IForkOptions = {
0 commit comments