@@ -79,7 +79,7 @@ describe('transformTypeToReferenceLink', () => {
7979 it ( 'should transform a function returning a Generic type' , ( ) => {
8080 strictEqual (
8181 transformTypeToReferenceLink ( '(err: Error) => Promise<boolean>' , { } ) ,
82- '(err: Error) => [`<Promise>`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`<boolean>`](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#boolean_type)>'
82+ '(err: [`< Error>`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error) ) => [`<Promise>`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`<boolean>`](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#boolean_type)>'
8383 ) ;
8484 } ) ;
8585
@@ -90,12 +90,26 @@ describe('transformTypeToReferenceLink', () => {
9090 ) ;
9191 } ) ;
9292
93- it ( 'should handle extreme nested combinations of functions, generics, unions, and intersections' , ( ) => {
93+ it ( 'should handle extreme nested combinations of functions, arrays, generics, unions, and intersections' , ( ) => {
9494 const input =
95- '(str: MyType) => Promise<Map<string, number & string>, Map<string | number>>' ;
95+ '(str: string[]) => Promise<Map<string, number & string>, Map<string | number>>' ;
96+
9697 const expected =
97- '(str: MyType ) => [`<Promise>`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`<Map>`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<[`<string>`](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type), [`<number>`](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type) & [`<string>`](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type)>, [`<Map>`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<[`<string>`](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type) | [`<number>`](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type)>>' ;
98+ '(str: [`<string>`](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type)[] ) => [`<Promise>`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[`<Map>`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<[`<string>`](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type), [`<number>`](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type) & [`<string>`](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type)>, [`<Map>`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map)<[`<string>`](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type) | [`<number>`](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#number_type)>>' ;
9899
99100 strictEqual ( transformTypeToReferenceLink ( input , { } ) , expected ) ;
100101 } ) ;
102+
103+ it ( 'should parse functions with array destructuring in callbacks returning functions with object destructuring' , ( ) => {
104+ const input =
105+ '(cb: ([first, second]: string[]) => void) => ({ id, name }: User) => boolean' ;
106+
107+ const expected =
108+ '(cb: ([first, second]: [`<string>`](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#string_type)[]) => `<void>`) => ({ id, name }: [`<User>`](userLink)) => [`<boolean>`](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#boolean_type)' ;
109+
110+ strictEqual (
111+ transformTypeToReferenceLink ( input , { User : 'userLink' } ) ,
112+ expected
113+ ) ;
114+ } ) ;
101115} ) ;
0 commit comments