@@ -15,17 +15,30 @@ export class Compiler {
15
15
private _files : ts . MapLike < { content : string , version : number } > ;
16
16
private _languageService : ts . LanguageService ;
17
17
18
- constructor ( compilerOptions ?: ts . CompilerOptions ) {
18
+ constructor ( compilerOptions ?: object ) {
19
19
20
- this . _compilerOptions = /* TS 2.0 */ Object . assign ( { skipLibCheck : true } , compilerOptions ) ;
20
+ function normalize ( path : string ) : string {
21
+ return path . replace ( / \\ / g, "/" ) ;
22
+ }
23
+
24
+ const { errors, options } = ts . convertCompilerOptionsFromJson (
25
+ /* TS 2.0 */ Object . assign ( { skipLibCheck : true } , compilerOptions || { } ) ,
26
+ normalize ( process . cwd ( ) )
27
+ ) ;
28
+ const [ error ] = errors ;
29
+ if ( error ) {
30
+ throw error ;
31
+ }
32
+
33
+ this . _compilerOptions = options ;
21
34
this . _files = { } ;
22
35
23
36
const languageServiceHost : ts . LanguageServiceHost = {
24
37
25
38
directoryExists : ts . sys . directoryExists ,
26
39
fileExists : ts . sys . fileExists ,
27
40
getCompilationSettings : ( ) => this . _compilerOptions ,
28
- getCurrentDirectory : ( ) => process . cwd ( ) ,
41
+ getCurrentDirectory : ( ) => normalize ( process . cwd ( ) ) ,
29
42
getDefaultLibFileName : ( options : ts . CompilerOptions ) => ts . getDefaultLibFilePath ( options ) ,
30
43
getScriptFileNames : ( ) => Object . keys ( this . _files ) ,
31
44
0 commit comments