@@ -1954,14 +1954,17 @@ module ts {
1954
1954
}
1955
1955
1956
1956
function emitLeadingDeclarationComments ( node : Node ) {
1957
- var leadingComments = getLeadingComments ( currentSourceFile . text , node . pos ) ;
1958
- emitNewLineBeforeLeadingComments ( node , leadingComments , writer ) ;
1959
- // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
1960
- emitComments ( leadingComments , /*trailingSeparator*/ true , writer , writeComment ) ;
1957
+ // Emit the leading comments only if the parent's pos doesnt match because parent should take care of emitting these comments
1958
+ if ( node . parent . kind === SyntaxKind . SourceFile || node . pos !== node . parent . pos ) {
1959
+ var leadingComments = getLeadingComments ( currentSourceFile . text , node . pos ) ;
1960
+ emitNewLineBeforeLeadingComments ( node , leadingComments , writer ) ;
1961
+ // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
1962
+ emitComments ( leadingComments , /*trailingSeparator*/ true , writer , writeComment ) ;
1963
+ }
1961
1964
}
1962
1965
1963
1966
function emitTrailingDeclarationComments ( node : Node ) {
1964
- // Emit the trailing declaration comments only if the parent's end doesnt match
1967
+ // Emit the trailing comments only if the parent's end doesnt match
1965
1968
if ( node . parent . kind === SyntaxKind . SourceFile || node . end !== node . parent . end ) {
1966
1969
var trailingComments = getTrailingComments ( currentSourceFile . text , node . end ) ;
1967
1970
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
0 commit comments