@@ -2051,20 +2051,19 @@ namespace ts {
2051
2051
2052
2052
function emitSourceFile ( node : SourceFile ) {
2053
2053
writeLine ( ) ;
2054
- // If the node is a sourceFile and it has prologueDirective (statmentOffSet is not zero) that is synthesize
2055
- // We will need to emit detached comment here because emitPrologueDirective will not emit comments of such prologue directive
2056
2054
const statements = node . statements ;
2057
- // Emit detached comment if there iare no prologue directives or this is a synthesized prologue directives.
2058
- // The synthesized node will have no leading comment so some comments may be missed .
2059
- const shouldEmitDetachedComment = statements . length === 0 ||
2060
- ! isPrologueDirective ( statements [ 0 ] ) ||
2061
- ( isPrologueDirective ( statements [ 0 ] ) && nodeIsSynthesized ( statements [ 0 ] ) ) ;
2062
- if ( emitBodyWithDetachedComments && shouldEmitDetachedComment ) {
2063
- emitBodyWithDetachedComments ( node , statements , emitSourceFileWorker ) ;
2064
- }
2065
- else {
2066
- emitSourceFileWorker ( node ) ;
2055
+ if ( emitBodyWithDetachedComments ) {
2056
+ // Emit detached comment if there iare no prologue directives or this is a synthesized prologue directives .
2057
+ // The synthesized node will have no leading comment so some comments may be missed.
2058
+ const shouldEmitDetachedComment = statements . length === 0 ||
2059
+ ! isPrologueDirective ( statements [ 0 ] ) ||
2060
+ nodeIsSynthesized ( statements [ 0 ] ) ;
2061
+ if ( shouldEmitDetachedComment ) {
2062
+ emitBodyWithDetachedComments ( node , statements , emitSourceFileWorker ) ;
2063
+ return ;
2064
+ }
2067
2065
}
2066
+ emitSourceFileWorker ( node ) ;
2068
2067
}
2069
2068
2070
2069
function emitSourceFileWorker ( node : SourceFile ) {
@@ -2111,7 +2110,7 @@ namespace ts {
2111
2110
}
2112
2111
2113
2112
function emitPrologueDirectivesIfNeeded ( sourceFileOrBundle : Bundle | SourceFile ) {
2114
- if ( sourceFileOrBundle . kind === SyntaxKind . SourceFile ) {
2113
+ if ( isSourceFile ( sourceFileOrBundle ) ) {
2115
2114
setSourceFile ( sourceFileOrBundle as SourceFile ) ;
2116
2115
emitPrologueDirectives ( ( sourceFileOrBundle as SourceFile ) . statements ) ;
2117
2116
}
@@ -2125,7 +2124,7 @@ namespace ts {
2125
2124
}
2126
2125
2127
2126
function emitShebangIfNeeded ( sourceFileOrBundle : Bundle | SourceFile ) {
2128
- if ( sourceFileOrBundle . kind === SyntaxKind . SourceFile ) {
2127
+ if ( isSourceFile ( sourceFileOrBundle ) ) {
2129
2128
const shebang = getShebang ( sourceFileOrBundle . text ) ;
2130
2129
if ( shebang ) {
2131
2130
write ( shebang ) ;
0 commit comments