@@ -188,7 +188,7 @@ namespace ts {
188
188
if ( ! moduleElementEmitInfo && asynchronousSubModuleDeclarationEmitInfo ) {
189
189
moduleElementEmitInfo = forEach ( asynchronousSubModuleDeclarationEmitInfo , declEmitInfo => declEmitInfo . node === nodeToCheck ? declEmitInfo : undefined ) ;
190
190
}
191
-
191
+
192
192
// If the alias was marked as not visible when we saw its declaration, we would have saved the aliasEmitInfo, but if we haven't yet visited the alias declaration
193
193
// then we don't need to write it at this point. We will write it when we actually see its declaration
194
194
// Eg.
@@ -198,7 +198,7 @@ namespace ts {
198
198
// we would write alias foo declaration when we visit it since it would now be marked as visible
199
199
if ( moduleElementEmitInfo ) {
200
200
if ( moduleElementEmitInfo . node . kind === SyntaxKind . ImportDeclaration ) {
201
- // we have to create asynchronous output only after we have collected complete information
201
+ // we have to create asynchronous output only after we have collected complete information
202
202
// because it is possible to enable multiple bindings as asynchronously visible
203
203
moduleElementEmitInfo . isVisible = true ;
204
204
}
@@ -353,6 +353,21 @@ namespace ts {
353
353
return emitEntityName ( < Identifier > type ) ;
354
354
case SyntaxKind . QualifiedName :
355
355
return emitEntityName ( < QualifiedName > type ) ;
356
+ case SyntaxKind . TypePredicate :
357
+ return emitTypePredicate ( < TypePredicateNode > type ) ;
358
+ }
359
+
360
+ function writeEntityName ( entityName : EntityName | Expression ) {
361
+ if ( entityName . kind === SyntaxKind . Identifier ) {
362
+ writeTextOfNode ( currentSourceFile , entityName ) ;
363
+ }
364
+ else {
365
+ let left = entityName . kind === SyntaxKind . QualifiedName ? ( < QualifiedName > entityName ) . left : ( < PropertyAccessExpression > entityName ) . expression ;
366
+ let right = entityName . kind === SyntaxKind . QualifiedName ? ( < QualifiedName > entityName ) . right : ( < PropertyAccessExpression > entityName ) . name ;
367
+ writeEntityName ( left ) ;
368
+ write ( "." ) ;
369
+ writeTextOfNode ( currentSourceFile , right ) ;
370
+ }
356
371
}
357
372
358
373
function emitEntityName ( entityName : EntityName | PropertyAccessExpression ) {
@@ -362,19 +377,6 @@ namespace ts {
362
377
363
378
handleSymbolAccessibilityError ( visibilityResult ) ;
364
379
writeEntityName ( entityName ) ;
365
-
366
- function writeEntityName ( entityName : EntityName | Expression ) {
367
- if ( entityName . kind === SyntaxKind . Identifier ) {
368
- writeTextOfNode ( currentSourceFile , entityName ) ;
369
- }
370
- else {
371
- let left = entityName . kind === SyntaxKind . QualifiedName ? ( < QualifiedName > entityName ) . left : ( < PropertyAccessExpression > entityName ) . expression ;
372
- let right = entityName . kind === SyntaxKind . QualifiedName ? ( < QualifiedName > entityName ) . right : ( < PropertyAccessExpression > entityName ) . name ;
373
- writeEntityName ( left ) ;
374
- write ( "." ) ;
375
- writeTextOfNode ( currentSourceFile , right ) ;
376
- }
377
- }
378
380
}
379
381
380
382
function emitExpressionWithTypeArguments ( node : ExpressionWithTypeArguments ) {
@@ -398,6 +400,12 @@ namespace ts {
398
400
}
399
401
}
400
402
403
+ function emitTypePredicate ( type : TypePredicateNode ) {
404
+ writeEntityName ( type . parameterName ) ;
405
+ write ( " is " ) ;
406
+ emitType ( type . type ) ;
407
+ }
408
+
401
409
function emitTypeQuery ( type : TypeQueryNode ) {
402
410
write ( "typeof " ) ;
403
411
emitEntityName ( type . exprName ) ;
@@ -600,7 +608,7 @@ namespace ts {
600
608
}
601
609
602
610
function writeImportEqualsDeclaration ( node : ImportEqualsDeclaration ) {
603
- // note usage of writer. methods instead of aliases created, just to make sure we are using
611
+ // note usage of writer. methods instead of aliases created, just to make sure we are using
604
612
// correct writer especially to handle asynchronous alias writing
605
613
emitJsDocComments ( node ) ;
606
614
if ( node . flags & NodeFlags . Export ) {
@@ -642,7 +650,7 @@ namespace ts {
642
650
643
651
function writeImportDeclaration ( node : ImportDeclaration ) {
644
652
if ( ! node . importClause && ! ( node . flags & NodeFlags . Export ) ) {
645
- // do not write non-exported import declarations that don't have import clauses
653
+ // do not write non-exported import declarations that don't have import clauses
646
654
return ;
647
655
}
648
656
emitJsDocComments ( node ) ;
@@ -1517,7 +1525,7 @@ namespace ts {
1517
1525
}
1518
1526
}
1519
1527
}
1520
- }
1528
+ }
1521
1529
}
1522
1530
1523
1531
function emitNode ( node : Node ) {
@@ -1577,7 +1585,7 @@ namespace ts {
1577
1585
referencePathsOutput += "/// <reference path=\"" + declFileName + "\" />" + newLine ;
1578
1586
}
1579
1587
}
1580
-
1588
+
1581
1589
/* @internal */
1582
1590
export function writeDeclarationFile ( jsFilePath : string , sourceFile : SourceFile , host : EmitHost , resolver : EmitResolver , diagnostics : Diagnostic [ ] ) {
1583
1591
let emitDeclarationResult = emitDeclarations ( host , resolver , diagnostics , jsFilePath , sourceFile ) ;
0 commit comments