@@ -11,12 +11,17 @@ namespace ts.server {
11
11
12
12
interface NodeChildProcess {
13
13
send ( message : any , sendHandle ?: any ) : void ;
14
+ on ( message : "message" , f : ( m : any ) => void ) : void ;
14
15
}
15
16
16
17
const childProcess : {
17
18
fork ( modulePath : string ) : NodeChildProcess ;
18
19
} = require ( "child_process" ) ;
19
20
21
+ const os : {
22
+ homedir ( ) : string
23
+ } = require ( "os" ) ;
24
+
20
25
interface ReadLineOptions {
21
26
input : NodeJS . ReadableStream ;
22
27
output ?: NodeJS . WritableStream ;
@@ -165,14 +170,20 @@ namespace ts.server {
165
170
private cachePath : string ;
166
171
167
172
constructor ( private readonly logger : server . Logger ) {
173
+ let basePath : string ;
168
174
switch ( process . platform ) {
169
175
case "win32" :
170
- this . cachePath = normalizeSlashes ( combinePaths ( process . env . LOCALAPPDATA || process . env . APPDATA , "Microsoft/TypeScript" ) ) ;
176
+ basePath = process . env . LOCALAPPDATA || process . env . APPDATA || os . homedir ( ) ;
171
177
break ;
172
- case "darwin" :
173
178
case "linux" :
174
- // TODO:
179
+ basePath = os . homedir ( ) ;
175
180
break ;
181
+ case "darwin" :
182
+ basePath = combinePaths ( os . homedir ( ) , "/Library/Application Support/" )
183
+ break ;
184
+ }
185
+ if ( basePath ) {
186
+ this . cachePath = combinePaths ( normalizeSlashes ( basePath ) , "/Microsoft/TypeScript" ) ;
176
187
}
177
188
}
178
189
@@ -183,7 +194,7 @@ namespace ts.server {
183
194
}
184
195
185
196
this . installer = childProcess . fork ( combinePaths ( __dirname , "typingsInstaller.js" ) ) ;
186
- ( < any > this . installer ) . on ( "message" , ( m : any ) => this . handleMessage ( m ) ) ;
197
+ this . installer . on ( "message" , m => this . handleMessage ( m ) ) ;
187
198
}
188
199
189
200
enqueueInstallTypingsRequest ( project : Project , typingOptions : TypingOptions ) : void {
0 commit comments