2
2
/// <reference path="session.ts" />
3
3
4
4
namespace ts . server {
5
- interface IoSessionOptions {
6
- host : ServerHost ;
7
- cancellationToken : ServerCancellationToken ;
8
- canUseEvents : boolean ;
9
- /**
10
- * If defined, specifies the socket used to send events to the client.
11
- * Otherwise, events are sent through the host.
12
- */
13
- eventPort ?: number ;
14
- useSingleInferredProject : boolean ;
15
- useInferredProjectPerProjectRoot : boolean ;
16
- disableAutomaticTypingAcquisition : boolean ;
17
- globalTypingsCacheLocation : string ;
18
- logger : Logger ;
19
- typingSafeListLocation : string ;
20
- typesMapLocation : string | undefined ;
21
- npmLocation : string | undefined ;
22
- telemetryEnabled : boolean ;
23
- globalPlugins : ReadonlyArray < string > ;
24
- pluginProbeLocations : ReadonlyArray < string > ;
25
- allowLocalPluginLoads : boolean ;
26
- }
27
-
28
5
const childProcess : {
29
6
fork ( modulePath : string , args : string [ ] , options ?: { execArgv : string [ ] , env ?: MapLike < string > } ) : NodeChildProcess ;
30
7
execFileSync ( file : string , args : string [ ] , options : { stdio : "ignore" , env : MapLike < string > } ) : string | Buffer ;
@@ -505,9 +482,7 @@ namespace ts.server {
505
482
private socketEventQueue : { body : any , eventName : string } [ ] | undefined ;
506
483
private constructed : boolean | undefined ;
507
484
508
- constructor ( options : IoSessionOptions ) {
509
- const { host, eventPort, globalTypingsCacheLocation, typingSafeListLocation, typesMapLocation, npmLocation, canUseEvents } = options ;
510
-
485
+ constructor ( ) {
511
486
const event : Event | undefined = ( body : object , eventName : string ) => {
512
487
if ( this . constructed ) {
513
488
this . event ( body , eventName ) ;
@@ -521,9 +496,11 @@ namespace ts.server {
521
496
}
522
497
} ;
523
498
499
+ const host = sys ;
500
+
524
501
const typingsInstaller = disableAutomaticTypingAcquisition
525
502
? undefined
526
- : new NodeTypingsInstaller ( telemetryEnabled , logger , host , globalTypingsCacheLocation , typingSafeListLocation , typesMapLocation , npmLocation , event ) ;
503
+ : new NodeTypingsInstaller ( telemetryEnabled , logger , host , getGlobalTypingsCacheLocation ( ) , typingSafeListLocation , typesMapLocation , npmLocation , event ) ;
527
504
528
505
super ( {
529
506
host,
@@ -534,10 +511,10 @@ namespace ts.server {
534
511
byteLength : Buffer . byteLength ,
535
512
hrtime : process . hrtime ,
536
513
logger,
537
- canUseEvents,
538
- globalPlugins : options . globalPlugins ,
539
- pluginProbeLocations : options . pluginProbeLocations ,
540
- allowLocalPluginLoads : options . allowLocalPluginLoads
514
+ canUseEvents : eventPort !== undefined ,
515
+ globalPlugins,
516
+ pluginProbeLocations,
517
+ allowLocalPluginLoads,
541
518
} ) ;
542
519
543
520
this . eventPort = eventPort ;
@@ -952,31 +929,12 @@ namespace ts.server {
952
929
const disableAutomaticTypingAcquisition = hasArgument ( "--disableAutomaticTypingAcquisition" ) ;
953
930
const telemetryEnabled = hasArgument ( Arguments . EnableTelemetry ) ;
954
931
955
- const options : IoSessionOptions = {
956
- host : sys ,
957
- cancellationToken,
958
- eventPort,
959
- canUseEvents : true ,
960
- useSingleInferredProject,
961
- useInferredProjectPerProjectRoot,
962
- disableAutomaticTypingAcquisition,
963
- globalTypingsCacheLocation : getGlobalTypingsCacheLocation ( ) ,
964
- typingSafeListLocation,
965
- typesMapLocation,
966
- npmLocation,
967
- telemetryEnabled,
968
- logger,
969
- globalPlugins,
970
- pluginProbeLocations,
971
- allowLocalPluginLoads
972
- } ;
973
-
974
932
logger . info ( `Starting TS Server` ) ;
975
933
logger . info ( `Version: ${ version } ` ) ;
976
934
logger . info ( `Arguments: ${ process . argv . join ( " " ) } ` ) ;
977
935
logger . info ( `Platform: ${ os . platform ( ) } NodeVersion: ${ nodeVersion } CaseSensitive: ${ sys . useCaseSensitiveFileNames } ` ) ;
978
936
979
- const ioSession = new IOSession ( options ) ;
937
+ const ioSession = new IOSession ( ) ;
980
938
process . on ( "uncaughtException" , err => {
981
939
ioSession . logError ( err , "unknown" ) ;
982
940
} ) ;
0 commit comments