@@ -1599,9 +1599,9 @@ module ts {
1599
1599
}
1600
1600
1601
1601
// Only perform incremental parsing on open files that are being edited. If a file was
1602
- // open, but is now closed, we want to reparse entirely so we don't have any tokens that
1602
+ // open, but is now closed, we want to re-parse entirely so we don't have any tokens that
1603
1603
// are holding onto expensive script snapshot instances on the host. Similarly, if a
1604
- // file was closed, then we always want to reparse . This is so our tree doesn't keep
1604
+ // file was closed, then we always want to re-parse . This is so our tree doesn't keep
1605
1605
// the old buffer alive that represented the file on disk (as the host has moved to a
1606
1606
// new text buffer).
1607
1607
var textChangeRange : TypeScript . TextChangeRange = null ;
@@ -1651,12 +1651,28 @@ module ts {
1651
1651
return program . getDiagnostics ( getSourceFile ( filename ) . getSourceFile ( ) ) ;
1652
1652
}
1653
1653
1654
+ // In a case when '-d' is not enabled, only report semantic errors
1655
+ // If '-d' enabled, report both semantic and emitter errors
1654
1656
function getSemanticDiagnostics ( filename : string ) {
1655
1657
synchronizeHostData ( ) ;
1656
1658
1657
1659
filename = TypeScript . switchToForwardSlashes ( filename )
1658
-
1659
- return getFullTypeCheckChecker ( ) . getDiagnostics ( getSourceFile ( filename ) ) ;
1660
+ var compilerOptions = program . getCompilerOptions ( ) ;
1661
+ var checker = getFullTypeCheckChecker ( ) ;
1662
+ var targetSourceFile = getSourceFile ( filename ) ;
1663
+
1664
+ // Only perform the action per file regardless off '-out' flag
1665
+ // As an errors message in Visual Studio will maintain an error message life-time per file
1666
+
1667
+ var allDiagnostics = checker . getDiagnostics ( targetSourceFile ) ;
1668
+ if ( compilerOptions . declaration ) {
1669
+ // If '-d' is enabled, check for emitter error which requires calling to TypeChecker.emitFiles
1670
+ // Define CompilerHost.writer which does nothing as this is a side effect of emitFiles
1671
+ writer = ( filename : string , data : string , writeByteOrderMark : boolean ) => { } ;
1672
+ allDiagnostics = allDiagnostics . concat ( checker . emitFiles ( targetSourceFile ) . errors ) ;
1673
+ writer = undefined ;
1674
+ }
1675
+ return allDiagnostics
1660
1676
}
1661
1677
1662
1678
function getCompilerOptionsDiagnostics ( ) {
0 commit comments