@@ -192,7 +192,7 @@ namespace ts {
192
192
export function nodePosToString ( node : Node ) : string {
193
193
const file = getSourceFileOfNode ( node ) ;
194
194
const loc = getLineAndCharacterOfPosition ( file , node . pos ) ;
195
- return `${ file . fileName } (${ loc . line + 1 } ,${ loc . character + 1 } )` ;
195
+ return `${ file . fileName } (${ loc . line + 1 } ,${ loc . character + 1 } )` ;
196
196
}
197
197
198
198
export function getStartPosOfNode ( node : Node ) : number {
@@ -439,7 +439,7 @@ namespace ts {
439
439
}
440
440
441
441
export function isBlockScope ( node : Node , parentNode : Node ) {
442
- switch ( node . kind ) {
442
+ switch ( node . kind ) {
443
443
case SyntaxKind . SourceFile :
444
444
case SyntaxKind . CaseBlock :
445
445
case SyntaxKind . CatchClause :
@@ -644,9 +644,9 @@ namespace ts {
644
644
645
645
export function getJsDocCommentsFromText ( node : Node , text : string ) {
646
646
const commentRanges = ( node . kind === SyntaxKind . Parameter ||
647
- node . kind === SyntaxKind . TypeParameter ||
648
- node . kind === SyntaxKind . FunctionExpression ||
649
- node . kind === SyntaxKind . ArrowFunction ) ?
647
+ node . kind === SyntaxKind . TypeParameter ||
648
+ node . kind === SyntaxKind . FunctionExpression ||
649
+ node . kind === SyntaxKind . ArrowFunction ) ?
650
650
concatenate ( getTrailingCommentRanges ( text , node . pos ) , getLeadingCommentRanges ( text , node . pos ) ) :
651
651
getLeadingCommentRangesOfNodeFromText ( node , text ) ;
652
652
return filter ( commentRanges , isJsDocComment ) ;
@@ -911,7 +911,7 @@ namespace ts {
911
911
export function isObjectLiteralOrClassExpressionMethod ( node : Node ) : node is MethodDeclaration {
912
912
return node . kind === SyntaxKind . MethodDeclaration &&
913
913
( node . parent . kind === SyntaxKind . ObjectLiteralExpression ||
914
- node . parent . kind === SyntaxKind . ClassExpression ) ;
914
+ node . parent . kind === SyntaxKind . ClassExpression ) ;
915
915
}
916
916
917
917
export function isIdentifierTypePredicate ( predicate : TypePredicate ) : predicate is IdentifierTypePredicate {
@@ -1133,8 +1133,8 @@ namespace ts {
1133
1133
// if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target;
1134
1134
return ( < FunctionLikeDeclaration > node . parent ) . body !== undefined
1135
1135
&& ( node . parent . kind === SyntaxKind . Constructor
1136
- || node . parent . kind === SyntaxKind . MethodDeclaration
1137
- || node . parent . kind === SyntaxKind . SetAccessor )
1136
+ || node . parent . kind === SyntaxKind . MethodDeclaration
1137
+ || node . parent . kind === SyntaxKind . SetAccessor )
1138
1138
&& node . parent . parent . kind === SyntaxKind . ClassDeclaration ;
1139
1139
}
1140
1140
@@ -1481,7 +1481,7 @@ namespace ts {
1481
1481
} , tags => tags ) ;
1482
1482
}
1483
1483
1484
- function getJSDocs < T > ( node : Node , checkParentVariableStatement : boolean , getDocs : ( docs : JSDoc [ ] ) => T [ ] , getTags : ( tags : JSDocTag [ ] ) => T [ ] ) : T [ ] {
1484
+ function getJSDocs < T > ( node : Node , checkParentVariableStatement : boolean , getDocs : ( docs : JSDoc [ ] ) => T [ ] , getTags : ( tags : JSDocTag [ ] ) => T [ ] ) : T [ ] {
1485
1485
// TODO: Get rid of getJsDocComments and friends (note the lowercase 's' in Js)
1486
1486
// TODO: A lot of this work should be cached, maybe. I guess it's only used in services right now...
1487
1487
let result : T [ ] = undefined ;
@@ -1502,8 +1502,8 @@ namespace ts {
1502
1502
1503
1503
const variableStatementNode =
1504
1504
isInitializerOfVariableDeclarationInStatement ? node . parent . parent . parent :
1505
- isVariableOfVariableDeclarationStatement ? node . parent . parent :
1506
- undefined ;
1505
+ isVariableOfVariableDeclarationStatement ? node . parent . parent :
1506
+ undefined ;
1507
1507
if ( variableStatementNode ) {
1508
1508
result = append ( result , getJSDocs ( variableStatementNode , checkParentVariableStatement , getDocs , getTags ) ) ;
1509
1509
}
@@ -1668,7 +1668,7 @@ namespace ts {
1668
1668
if ( ( < ShorthandPropertyAssignment > parent ) . name !== node ) {
1669
1669
return AssignmentKind . None ;
1670
1670
}
1671
- // Fall through
1671
+ // Fall through
1672
1672
case SyntaxKind . PropertyAssignment :
1673
1673
node = parent . parent ;
1674
1674
break ;
@@ -2570,14 +2570,18 @@ namespace ts {
2570
2570
if ( options . outFile || options . out ) {
2571
2571
const moduleKind = getEmitModuleKind ( options ) ;
2572
2572
const moduleEmitEnabled = moduleKind === ModuleKind . AMD || moduleKind === ModuleKind . System ;
2573
- const sourceFiles = host . getSourceFiles ( ) ;
2573
+ const sourceFiles = getAllEmittableSourceFiles ( ) ;
2574
2574
// Can emit only sources that are not declaration file and are either non module code or module with --module or --target es6 specified
2575
2575
return filter ( sourceFiles , moduleEmitEnabled ? isNonDeclarationFile : isBundleEmitNonExternalModule ) ;
2576
2576
}
2577
2577
else {
2578
- const sourceFiles = targetSourceFile === undefined ? host . getSourceFiles ( ) : [ targetSourceFile ] ;
2578
+ const sourceFiles = targetSourceFile === undefined ? getAllEmittableSourceFiles ( ) : [ targetSourceFile ] ;
2579
2579
return filter ( sourceFiles , isNonDeclarationFile ) ;
2580
2580
}
2581
+
2582
+ function getAllEmittableSourceFiles ( ) {
2583
+ return options . noEmitForJsFiles ? filter ( host . getSourceFiles ( ) , sourceFile => ! isSourceFileJavaScript ( sourceFile ) ) : host . getSourceFiles ( ) ;
2584
+ }
2581
2585
}
2582
2586
2583
2587
function isNonDeclarationFile ( sourceFile : SourceFile ) {
@@ -2609,7 +2613,7 @@ namespace ts {
2609
2613
}
2610
2614
else {
2611
2615
for ( const sourceFile of sourceFiles ) {
2612
- // Don't emit if source file is a declaration file, or was located under node_modules
2616
+ // Don't emit if source file is a declaration file, or was located under node_modules
2613
2617
if ( ! isDeclarationFile ( sourceFile ) && ! host . isSourceFileFromExternalLibrary ( sourceFile ) ) {
2614
2618
onSingleFileEmit ( host , sourceFile ) ;
2615
2619
}
@@ -2671,7 +2675,7 @@ namespace ts {
2671
2675
onBundledEmit ( host ) ;
2672
2676
}
2673
2677
else {
2674
- const sourceFiles = targetSourceFile === undefined ? host . getSourceFiles ( ) : [ targetSourceFile ] ;
2678
+ const sourceFiles = targetSourceFile === undefined ? getSourceFilesToEmit ( host ) : [ targetSourceFile ] ;
2675
2679
for ( const sourceFile of sourceFiles ) {
2676
2680
// Don't emit if source file is a declaration file, or was located under node_modules
2677
2681
if ( ! isDeclarationFile ( sourceFile ) && ! host . isSourceFileFromExternalLibrary ( sourceFile ) ) {
@@ -2709,11 +2713,11 @@ namespace ts {
2709
2713
function onBundledEmit ( host : EmitHost ) {
2710
2714
// Can emit only sources that are not declaration file and are either non module code or module with
2711
2715
// --module or --target es6 specified. Files included by searching under node_modules are also not emitted.
2712
- const bundledSources = filter ( host . getSourceFiles ( ) ,
2716
+ const bundledSources = filter ( getSourceFilesToEmit ( host ) ,
2713
2717
sourceFile => ! isDeclarationFile ( sourceFile ) &&
2714
- ! host . isSourceFileFromExternalLibrary ( sourceFile ) &&
2715
- ( ! isExternalModule ( sourceFile ) ||
2716
- ! ! getEmitModuleKind ( options ) ) ) ;
2718
+ ! host . isSourceFileFromExternalLibrary ( sourceFile ) &&
2719
+ ( ! isExternalModule ( sourceFile ) ||
2720
+ ! ! getEmitModuleKind ( options ) ) ) ;
2717
2721
if ( bundledSources . length ) {
2718
2722
const jsFilePath = options . outFile || options . out ;
2719
2723
const emitFileNames : EmitFileNames = {
@@ -2899,7 +2903,7 @@ namespace ts {
2899
2903
writeComment : ( text : string , lineMap : number [ ] , writer : EmitTextWriter , commentPos : number , commentEnd : number , newLine : string ) => void ,
2900
2904
node : TextRange , newLine : string , removeComments : boolean ) {
2901
2905
let leadingComments : CommentRange [ ] ;
2902
- let currentDetachedCommentInfo : { nodePos : number , detachedCommentEndPos : number } ;
2906
+ let currentDetachedCommentInfo : { nodePos : number , detachedCommentEndPos : number } ;
2903
2907
if ( removeComments ) {
2904
2908
// removeComments is true, only reserve pinned comment at the top of file
2905
2909
// For example:
@@ -3246,10 +3250,10 @@ namespace ts {
3246
3250
3247
3251
function stringifyValue ( value : any ) : string {
3248
3252
return typeof value === "string" ? `"${ escapeString ( value ) } "`
3249
- : typeof value === "number" ? isFinite ( value ) ? String ( value ) : "null"
3250
- : typeof value === "boolean" ? value ? "true" : "false"
3251
- : typeof value === "object" && value ? isArray ( value ) ? cycleCheck ( stringifyArray , value ) : cycleCheck ( stringifyObject , value )
3252
- : /*fallback*/ "null" ;
3253
+ : typeof value === "number" ? isFinite ( value ) ? String ( value ) : "null"
3254
+ : typeof value === "boolean" ? value ? "true" : "false"
3255
+ : typeof value === "object" && value ? isArray ( value ) ? cycleCheck ( stringifyArray , value ) : cycleCheck ( stringifyObject , value )
3256
+ : /*fallback*/ "null" ;
3253
3257
}
3254
3258
3255
3259
function cycleCheck ( cb : ( value : any ) => string , value : any ) {
@@ -3274,7 +3278,7 @@ namespace ts {
3274
3278
3275
3279
function stringifyProperty ( memo : string , value : any , key : string ) {
3276
3280
return value === undefined || typeof value === "function" || key === "__cycle" ? memo
3277
- : ( memo ? memo + "," : memo ) + `"${ escapeString ( key ) } ":${ stringifyValue ( value ) } ` ;
3281
+ : ( memo ? memo + "," : memo ) + `"${ escapeString ( key ) } ":${ stringifyValue ( value ) } ` ;
3278
3282
}
3279
3283
3280
3284
const base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" ;
@@ -3519,7 +3523,7 @@ namespace ts {
3519
3523
* @param token The token.
3520
3524
*/
3521
3525
export function createTokenRange ( pos : number , token : SyntaxKind ) : TextRange {
3522
- return createRange ( pos , pos + tokenToString ( token ) . length ) ;
3526
+ return createRange ( pos , pos + tokenToString ( token ) . length ) ;
3523
3527
}
3524
3528
3525
3529
export function rangeIsOnSingleLine ( range : TextRange , sourceFile : SourceFile ) {
0 commit comments