@@ -93,6 +93,33 @@ namespace ts {
93
93
} ) ;
94
94
} ) ;
95
95
96
+ describe ( "No duplicate ref directives when emiting .d.ts->.d.ts" , ( ) => {
97
+ it ( "without statements" , ( ) => {
98
+ const host = new fakes . CompilerHost ( new vfs . FileSystem ( true , {
99
+ files : {
100
+ "/test.d.ts" : `/// <reference types="node" />\n/// <reference path="./src/test.d.ts />\n`
101
+ }
102
+ } ) ) ;
103
+ const program = createProgram ( [ "/test.d.ts" ] , { } , host ) ;
104
+ const file = program . getSourceFile ( "/test.d.ts" ) ! ;
105
+ const printer = createPrinter ( { newLine : NewLineKind . CarriageReturnLineFeed } ) ;
106
+ const output = printer . printFile ( file ) ;
107
+ assert . equal ( output . split ( / \r ? \n / g) . length , 3 ) ;
108
+ } ) ;
109
+ it ( "with statements" , ( ) => {
110
+ const host = new fakes . CompilerHost ( new vfs . FileSystem ( true , {
111
+ files : {
112
+ "/test.d.ts" : `/// <reference types="node" />\n/// <reference path="./src/test.d.ts />\nvar a: number;\n`
113
+ }
114
+ } ) ) ;
115
+ const program = createProgram ( [ "/test.d.ts" ] , { } , host ) ;
116
+ const file = program . getSourceFile ( "/test.d.ts" ) ! ;
117
+ const printer = createPrinter ( { newLine : NewLineKind . CarriageReturnLineFeed } ) ;
118
+ const output = printer . printFile ( file ) ;
119
+ assert . equal ( output . split ( / \r ? \n / g) . length , 4 ) ;
120
+ } ) ;
121
+ } ) ;
122
+
96
123
describe ( "printBundle" , ( ) => {
97
124
const printsCorrectly = makePrintsCorrectly ( "printsBundleCorrectly" ) ;
98
125
let bundle : Bundle ;
0 commit comments