1- /// <reference path="..\compiler\commandLineParser.ts" />
2- /// <reference path="..\services\services.ts" />
3- /// <reference path="session.ts" />
1+ /// <reference path="program.ts" />
2+
3+ namespace ts {
4+ export interface EmitOutput {
5+ outputFiles : OutputFile [ ] ;
6+ emitSkipped : boolean ;
7+ }
8+
9+ export interface OutputFile {
10+ name : string ;
11+ writeByteOrderMark : boolean ;
12+ text : string ;
13+ }
414
5- namespace ts . server {
615 export interface Builder {
716 /**
817 * This is the callback when file infos in the builder are updated
@@ -13,6 +22,20 @@ namespace ts.server {
1322 clear ( ) : void ;
1423 }
1524
25+ export function getFileEmitOutput ( program : Program , sourceFile : SourceFile , emitOnlyDtsFiles ?: boolean ,
26+ cancellationToken ?: CancellationToken , customTransformers ?: CustomTransformers ) : EmitOutput {
27+ const outputFiles : OutputFile [ ] = [ ] ;
28+ const emitOutput = program . emit ( sourceFile , writeFile , cancellationToken , emitOnlyDtsFiles , customTransformers ) ;
29+ return {
30+ outputFiles,
31+ emitSkipped : emitOutput . emitSkipped
32+ } ;
33+
34+ function writeFile ( fileName : string , text : string , writeByteOrderMark : boolean ) {
35+ outputFiles . push ( { name : fileName , writeByteOrderMark, text } ) ;
36+ }
37+ }
38+
1639 interface EmitHandler {
1740 addScriptInfo ( program : Program , sourceFile : SourceFile ) : void ;
1841 removeScriptInfo ( path : Path ) : void ;
@@ -157,7 +180,7 @@ namespace ts.server {
157180 for ( const importName of sourceFile . imports ) {
158181 const symbol = checker . getSymbolAtLocation ( importName ) ;
159182 if ( symbol && symbol . declarations && symbol . declarations [ 0 ] ) {
160- const declarationSourceFile = symbol . declarations [ 0 ] . getSourceFile ( ) ;
183+ const declarationSourceFile = getSourceFileOfNode ( symbol . declarations [ 0 ] ) ;
161184 if ( declarationSourceFile ) {
162185 referencedFiles . set ( declarationSourceFile . path , true ) ;
163186 }
0 commit comments