@@ -33,13 +33,13 @@ function extractIdentifiersFromNodeAndChildren(
33
33
}
34
34
35
35
function extractTypeDeclaration ( fileName : string ) : string {
36
- const compilerOptions = { declaration : true ,
37
- emitDeclarationOnly : true }
38
- let dtsSource : string ;
39
- const host = ts . createCompilerHost ( compilerOptions ) ;
40
- host . writeFile = ( fileName : string , contents : string ) => dtsSource = contents ;
36
+ const compilerOptions = { declaration : true , emitDeclarationOnly : true } ;
37
+ let dtsSource : string ;
38
+ const host = ts . createCompilerHost ( compilerOptions ) ;
39
+ host . writeFile = ( fileName : string , contents : string ) =>
40
+ ( dtsSource = contents ) ;
41
41
const program = ts . createProgram ( [ fileName ] , compilerOptions , host ) ;
42
- program . emit ( )
42
+ program . emit ( ) ;
43
43
return dtsSource ! ;
44
44
}
45
45
@@ -57,10 +57,14 @@ export function extractPublicIdentifiers(filePaths: string[]): Set<string> {
57
57
contents ,
58
58
ts . ScriptTarget . ES2015
59
59
) ;
60
-
60
+
61
61
if ( ! sourceFile . isDeclarationFile ) {
62
- const dtsSource = extractTypeDeclaration ( filePath ) ;
63
- sourceFile = ts . createSourceFile ( filePath . replace ( ".ts" , ".d.ts" ) , dtsSource , ts . ScriptTarget . ES2015 ) ;
62
+ const dtsSource = extractTypeDeclaration ( filePath ) ;
63
+ sourceFile = ts . createSourceFile (
64
+ filePath . replace ( '.ts' , '.d.ts' ) ,
65
+ dtsSource ,
66
+ ts . ScriptTarget . ES2015
67
+ ) ;
64
68
}
65
69
66
70
const identifiers = new Set < string > ( ) ;
0 commit comments