@@ -72,18 +72,28 @@ namespace ts {
7272 directoryExists ( directoryName : string ) : boolean ;
7373 }
7474
75- /** Public interface of the the of a config service shim instance.*/
76- export interface CoreServicesShimHost extends Logger , ModuleResolutionHost {
75+ /** Public interface of the core-services host instance used in managed side */
76+ export interface CoreServicesShimHost extends Logger {
77+ directoryExists ( directoryName : string ) : boolean ;
78+ fileExists ( fileName : string ) : boolean ;
79+ getCurrentDirectory ( ) : string ;
80+ getDirectories ( path : string ) : string ;
81+
7782 /**
7883 * Returns a JSON-encoded value of the type: string[]
7984 *
8085 * @param exclude A JSON encoded string[] containing the paths to exclude
8186 * when enumerating the directory.
8287 */
8388 readDirectory ( rootDir : string , extension : string , basePaths ?: string , excludeEx ?: string , includeFileEx ?: string , includeDirEx ?: string , depth ?: number ) : string ;
84- useCaseSensitiveFileNames ?( ) : boolean ;
85- getCurrentDirectory ( ) : string ;
89+
90+ /**
91+ * Read arbitary text files on disk, i.e. when resolution procedure needs the content of 'package.json' to determine location of bundled typings for node modules
92+ */
93+ readFile ( fileName : string ) : string ;
94+ realpath ?( path : string ) : string ;
8695 trace ( s : string ) : void ;
96+ useCaseSensitiveFileNames ?( ) : boolean ;
8797 }
8898
8999 ///
@@ -240,6 +250,7 @@ namespace ts {
240250 }
241251
242252 export interface CoreServicesShim extends Shim {
253+ getAutomaticTypeDirectiveNames ( compilerOptionsJson : string ) : string ;
243254 getPreProcessedFileInfo ( fileName : string , sourceText : IScriptSnapshot ) : string ;
244255 getTSConfigFileInfo ( fileName : string , sourceText : IScriptSnapshot ) : string ;
245256 getDefaultCompilationSettings ( ) : string ;
@@ -492,6 +503,10 @@ namespace ts {
492503 private readDirectoryFallback ( rootDir : string , extension : string , exclude : string [ ] ) {
493504 return JSON . parse ( this . shimHost . readDirectory ( rootDir , extension , JSON . stringify ( exclude ) ) ) ;
494505 }
506+
507+ public getDirectories ( path : string ) : string [ ] {
508+ return JSON . parse ( this . shimHost . getDirectories ( path ) ) ;
509+ }
495510 }
496511
497512 function simpleForwardCall ( logger : Logger , actionDescription : string , action : ( ) => any , logPerformance : boolean ) : any {
@@ -1003,7 +1018,7 @@ namespace ts {
10031018
10041019 public getPreProcessedFileInfo ( fileName : string , sourceTextSnapshot : IScriptSnapshot ) : string {
10051020 return this . forwardJSONCall (
1006- " getPreProcessedFileInfo('" + fileName + "')" ,
1021+ ` getPreProcessedFileInfo('${ fileName } ')` ,
10071022 ( ) => {
10081023 // for now treat files as JavaScript
10091024 const result = preProcessFile ( sourceTextSnapshot . getText ( 0 , sourceTextSnapshot . getLength ( ) ) , /* readImportFiles */ true , /* detectJavaScriptImports */ true ) ;
@@ -1017,6 +1032,16 @@ namespace ts {
10171032 } ) ;
10181033 }
10191034
1035+ public getAutomaticTypeDirectiveNames ( compilerOptionsJson : string ) : string {
1036+ return this . forwardJSONCall (
1037+ `getAutomaticTypeDirectiveNames('${ compilerOptionsJson } ')` ,
1038+ ( ) => {
1039+ const compilerOptions = < CompilerOptions > JSON . parse ( compilerOptionsJson ) ;
1040+ return getAutomaticTypeDirectiveNames ( compilerOptions , this . host ) ;
1041+ }
1042+ ) ;
1043+ }
1044+
10201045 private convertFileReferences ( refs : FileReference [ ] ) : IFileReference [ ] {
10211046 if ( ! refs ) {
10221047 return undefined ;
0 commit comments