@@ -222,18 +222,17 @@ describe("JSDocTsdParser.parse.function", () => {
222
222
expect ( functionData . returns [ 0 ] . type . names . length ) . to . equal ( 1 ) ;
223
223
224
224
// add different array parameters to the function
225
+ // be sure that the types passed below are a valid return value of jsdoc, e.g. JSDoc transforms string[] to Array.<string>
225
226
functionData . params = [
226
227
{
227
228
name : "param1" ,
228
229
type : {
229
230
names : [
230
231
"Array.<string>" ,
231
232
"array.<boolean>" ,
232
- "object[] " ,
233
+ "Array.< object> " ,
233
234
"array" ,
234
235
"Array" ,
235
- "[]" ,
236
- "*[]" ,
237
236
"Array.<*>" ,
238
237
"array.<*>"
239
238
]
@@ -252,20 +251,20 @@ describe("JSDocTsdParser.parse.function", () => {
252
251
253
252
// ensure that every type is mapped correctly
254
253
let union = functionDeclarations [ 0 ] . parameters [ 0 ] . type as dom . UnionType ;
255
- expect ( union . members . length ) . to . eq ( 9 ) ;
254
+ expect ( union . members . length ) . to . eq ( 7 ) ;
256
255
257
256
expect ( ( union . members [ 0 ] as any ) . kind ) . to . eq ( "array" ) ;
258
257
expect ( ( union . members [ 0 ] as any ) . type ) . to . eq ( dom . type . string ) ;
259
258
expect ( ( union . members [ 1 ] as any ) . kind ) . to . eq ( "array" ) ;
260
259
expect ( ( union . members [ 1 ] as any ) . type ) . to . eq ( dom . type . boolean ) ;
261
260
expect ( ( union . members [ 2 ] as any ) . kind ) . to . eq ( "array" ) ;
262
261
expect ( ( union . members [ 2 ] as any ) . type ) . to . eq ( dom . type . object ) ;
263
- expect ( union . members [ 3 ] ) . to . eq ( dom . type . any ) ;
264
- expect ( union . members [ 4 ] ) . to . eq ( dom . type . any ) ;
265
- expect ( union . members [ 5 ] ) . to . eq ( dom . type . any ) ;
266
- expect ( union . members [ 6 ] ) . to . eq ( dom . type . any ) ;
267
- expect ( union . members [ 7 ] ) . to . eq ( dom . type . any ) ;
268
- expect ( union . members [ 8 ] ) . to . eq ( dom . type . any ) ;
262
+
263
+ const anyArray = dom . type . array ( dom . type . any ) ;
264
+ expect ( union . members [ 3 ] ) . to . deep . eq ( anyArray ) ;
265
+ expect ( union . members [ 4 ] ) . to . deep . eq ( anyArray ) ;
266
+ expect ( union . members [ 5 ] ) . to . deep . eq ( anyArray ) ;
267
+ expect ( union . members [ 6 ] ) . to . deep . eq ( anyArray ) ;
269
268
270
269
} ) ;
271
270
@@ -287,8 +286,8 @@ describe("JSDocTsdParser.parse.function", () => {
287
286
names : [
288
287
"bool" ,
289
288
"boolean" ,
290
- "bool[] " ,
291
- "boolean[] "
289
+ "Array.< bool> " ,
290
+ "Array.< boolean> "
292
291
]
293
292
} ,
294
293
comment : ".." ,
@@ -360,7 +359,6 @@ describe("JSDocTsdParser.parse.function", () => {
360
359
description : ".." ,
361
360
type : {
362
361
names : [
363
- primitiveTypeValue + "[]" ,
364
362
"Array.<" + primitiveTypeValue + ">"
365
363
]
366
364
}
@@ -374,11 +372,9 @@ describe("JSDocTsdParser.parse.function", () => {
374
372
expect ( functionDeclarations . length ) . to . eq ( 1 ) ;
375
373
376
374
let union = functionDeclarations [ 0 ] . returnType as dom . UnionType ;
377
- expect ( union . members . length ) . to . eq ( 2 ) ;
375
+ expect ( union . members . length ) . to . eq ( 1 ) ;
378
376
expect ( ( union . members [ 0 ] as any ) . kind ) . to . eq ( "array" ) ;
379
377
expect ( ( union . members [ 0 ] as any ) . type ) . to . eq ( primitiveTypeValue ) ;
380
- expect ( ( union . members [ 1 ] as any ) . kind ) . to . eq ( "array" ) ;
381
- expect ( ( union . members [ 1 ] as any ) . type ) . to . eq ( primitiveTypeValue ) ;
382
378
}
383
379
} ) ;
384
380
0 commit comments