@@ -97,4 +97,66 @@ describe("built-in transpile", () => {
9797 ] ) ;
9898 } ) ;
9999 } ) ;
100+
101+ describe ( "failing to emit" , ( ) => {
102+ test ( "raises error with helpful message" , async ( ) => {
103+ await expect ( async ( ) =>
104+ testTranspileToDts ( [
105+ `export interface Foo {` ,
106+ ` p: {` ,
107+ ` [K in keyof P]: string;` ,
108+ ` },` ,
109+ `}` ,
110+ ] ) ,
111+ ) . rejects . toThrow (
112+ / ^ A p r o b l e m o c c u r r e d d u r i n g t r a n s p i l a t i o n a n d f i l e s w e r e n o t g e n e r a t e d \. { 2 } C o n t a c t t h e p l u g i n a u t h o r f o r s u p p o r t \. \n / ,
113+ ) ;
114+ } ) ;
115+ test ( "raises error with diagnostics" , async ( ) => {
116+ await expect ( async ( ) =>
117+ testTranspileToDts ( [
118+ `export interface Foo {` ,
119+ ` p: {` ,
120+ ` [K in keyof P]: string;` ,
121+ ` },` ,
122+ `}` ,
123+ ] ) ,
124+ ) . rejects . toThrow (
125+ / t e s t \. t s \( 3 , 1 7 \) : e r r o r T S 4 0 3 3 : P r o p e r t y ' p ' o f e x p o r t e d i n t e r f a c e h a s o r i s u s i n g p r i v a t e n a m e ' P ' \. $ / ,
126+ ) ;
127+ } ) ;
128+ test ( "raises error with 3 diagnostics, and elides the rest" , async ( ) => {
129+ await expect ( async ( ) =>
130+ testTranspileToDts ( [
131+ `export interface Foo1 {` ,
132+ ` p: {` ,
133+ ` [K in keyof P]: string;` ,
134+ ` },` ,
135+ `}` ,
136+ `export interface Foo2 {` ,
137+ ` p: {` ,
138+ ` [K in keyof P]: string;` ,
139+ ` },` ,
140+ `}` ,
141+ `export interface Foo3 {` ,
142+ ` p: {` ,
143+ ` [K in keyof P]: string;` ,
144+ ` },` ,
145+ `}` ,
146+ `export interface Foo4 {` ,
147+ ` p: {` ,
148+ ` [K in keyof P]: string;` ,
149+ ` },` ,
150+ `}` ,
151+ `export interface Foo5 {` ,
152+ ` p: {` ,
153+ ` [K in keyof P]: string;` ,
154+ ` },` ,
155+ `}` ,
156+ ] ) ,
157+ ) . rejects . toThrow (
158+ / (?: t e s t \. t s \( \d + , \d + \) : .+ \n ) { 3 } 2 m o r e d i a g n o s t i c s e l i d e d / ,
159+ ) ;
160+ } ) ;
161+ } ) ;
100162} ) ;
0 commit comments