File tree 2 files changed +35
-0
lines changed
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -255,6 +255,9 @@ export const typify = (
255
255
// we'll have to qualify it with the Node.js namespace.
256
256
return 'NodeJS.ReadableStream' ;
257
257
}
258
+ // Custom type
259
+ if ( innerTypes )
260
+ return `${ typeAsString } <${ innerTypes . map ( ( innerType ) => typify ( innerType ) ) . join ( ', ' ) } >` ;
258
261
return typeAsString ;
259
262
} ;
260
263
export const paramify = ( paramName : string ) => {
Original file line number Diff line number Diff line change @@ -102,6 +102,38 @@ describe('utils', () => {
102
102
it ( 'should map node objects to the correct type' , ( ) => {
103
103
expect ( utils . typify ( 'buffer' ) ) . toEqual ( 'Buffer' ) ;
104
104
} ) ;
105
+
106
+ it ( 'should convert custom types with inner types' , ( ) => {
107
+ expect (
108
+ utils . typify ( {
109
+ collection : false ,
110
+ innerTypes : [
111
+ {
112
+ collection : false ,
113
+ type : 'T' ,
114
+ } ,
115
+ ] ,
116
+ type : 'Foo' ,
117
+ } ) ,
118
+ ) . toEqual ( 'Foo<T>' ) ;
119
+
120
+ expect (
121
+ utils . typify ( {
122
+ collection : false ,
123
+ innerTypes : [
124
+ {
125
+ collection : false ,
126
+ type : 'A' ,
127
+ } ,
128
+ {
129
+ collection : false ,
130
+ type : 'B' ,
131
+ } ,
132
+ ] ,
133
+ type : 'Foo' ,
134
+ } ) ,
135
+ ) . toEqual ( 'Foo<A, B>' ) ;
136
+ } ) ;
105
137
} ) ;
106
138
107
139
describe ( 'paramify' , ( ) => {
You can’t perform that action at this time.
0 commit comments