@@ -12,6 +12,7 @@ namespace ts {
1212 // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature
1313 export function emitFiles ( resolver : EmitResolver , host : EmitHost , targetSourceFile : SourceFile , emitOnlyDtsFiles ?: boolean ) : EmitResult {
1414 const compilerOptions = host . getCompilerOptions ( ) ;
15+ const moduleKind = getEmitModuleKind ( compilerOptions ) ;
1516 const sourceMapDataList : SourceMapData [ ] = compilerOptions . sourceMap || compilerOptions . inlineSourceMap ? [ ] : undefined ;
1617 const emittedFilesList : string [ ] = compilerOptions . listEmittedFiles ? [ ] : undefined ;
1718 const emitterDiagnostics = createDiagnosticCollection ( ) ;
@@ -147,6 +148,10 @@ namespace ts {
147148 function emitHelpers ( node : Node , writeLines : ( text : string ) => void ) {
148149 let helpersEmitted = false ;
149150 const bundle = node . kind === SyntaxKind . Bundle ? < Bundle > node : undefined ;
151+ if ( bundle && moduleKind === ModuleKind . None ) {
152+ return ;
153+ }
154+
150155 const numNodes = bundle ? bundle . sourceFiles . length : 1 ;
151156 for ( let i = 0 ; i < numNodes ; i ++ ) {
152157 const currentNode = bundle ? bundle . sourceFiles [ i ] : node ;
@@ -201,7 +206,6 @@ namespace ts {
201206
202207 const newLine = getNewLineCharacter ( printerOptions ) ;
203208 const languageVersion = getEmitScriptTarget ( printerOptions ) ;
204- const moduleKind = getEmitModuleKind ( printerOptions ) ;
205209 const comments = createCommentWriter ( printerOptions , onEmitSourceMapOfPosition ) ;
206210 const {
207211 emitNodeWithComments,
@@ -257,9 +261,7 @@ namespace ts {
257261 function writeBundle ( bundle : Bundle , output : EmitTextWriter ) {
258262 const previousWriter = writer ;
259263 setWriter ( output ) ;
260- if ( moduleKind ) {
261- emitHelpersIndirect ( bundle ) ;
262- }
264+ emitHelpersIndirect ( bundle ) ;
263265 for ( const sourceFile of bundle . sourceFiles ) {
264266 print ( EmitHint . SourceFile , sourceFile , sourceFile ) ;
265267 }
@@ -280,11 +282,8 @@ namespace ts {
280282 }
281283
282284 function endPrint ( ) {
283- const text = writer . getText ( ) ;
284- if ( writer === ownWriter ) {
285- writer . reset ( ) ;
286- }
287-
285+ const text = ownWriter . getText ( ) ;
286+ ownWriter . reset ( ) ;
288287 return text ;
289288 }
290289
@@ -385,6 +384,15 @@ namespace ts {
385384
386385 function pipelineEmitUnspecified ( node : Node ) : void {
387386 const kind = node . kind ;
387+
388+ // Reserved words
389+ // Strict mode reserved words
390+ // Contextual keywords
391+ if ( isKeyword ( kind ) ) {
392+ writeTokenText ( kind ) ;
393+ return ;
394+ }
395+
388396 switch ( kind ) {
389397 // Pseudo-literals
390398 case SyntaxKind . TemplateHead :
@@ -396,46 +404,6 @@ namespace ts {
396404 case SyntaxKind . Identifier :
397405 return emitIdentifier ( < Identifier > node ) ;
398406
399- // Reserved words
400- case SyntaxKind . ConstKeyword :
401- case SyntaxKind . DefaultKeyword :
402- case SyntaxKind . ExportKeyword :
403- case SyntaxKind . VoidKeyword :
404-
405- // Strict mode reserved words
406- case SyntaxKind . PrivateKeyword :
407- case SyntaxKind . ProtectedKeyword :
408- case SyntaxKind . PublicKeyword :
409- case SyntaxKind . StaticKeyword :
410-
411- // Contextual keywords
412- case SyntaxKind . AbstractKeyword :
413- case SyntaxKind . AsKeyword :
414- case SyntaxKind . AnyKeyword :
415- case SyntaxKind . AsyncKeyword :
416- case SyntaxKind . AwaitKeyword :
417- case SyntaxKind . BooleanKeyword :
418- case SyntaxKind . ConstructorKeyword :
419- case SyntaxKind . DeclareKeyword :
420- case SyntaxKind . GetKeyword :
421- case SyntaxKind . IsKeyword :
422- case SyntaxKind . ModuleKeyword :
423- case SyntaxKind . NamespaceKeyword :
424- case SyntaxKind . NeverKeyword :
425- case SyntaxKind . ReadonlyKeyword :
426- case SyntaxKind . RequireKeyword :
427- case SyntaxKind . NumberKeyword :
428- case SyntaxKind . SetKeyword :
429- case SyntaxKind . StringKeyword :
430- case SyntaxKind . SymbolKeyword :
431- case SyntaxKind . TypeKeyword :
432- case SyntaxKind . UndefinedKeyword :
433- case SyntaxKind . FromKeyword :
434- case SyntaxKind . GlobalKeyword :
435- case SyntaxKind . OfKeyword :
436- writeTokenText ( kind ) ;
437- return ;
438-
439407 // Parse tree nodes
440408
441409 // Names
0 commit comments