@@ -27,7 +27,14 @@ import {
2727 getTopLevelOrderedTypes ,
2828 convertListToTypedKeys ,
2929} from '../src/markdown-helpers.js' ;
30- import { DocumentationTag } from '../src/ParsedDocumentation.js' ;
30+ import {
31+ DocumentationTag ,
32+ type DetailedFunctionType ,
33+ type DetailedObjectType ,
34+ type DetailedStringType ,
35+ type DetailedEventType ,
36+ type DetailedEventReferenceType ,
37+ } from '../src/ParsedDocumentation.js' ;
3138
3239const getTokens = ( md : string ) => {
3340 const markdown = new MarkdownIt ( { html : true } ) ;
@@ -1314,8 +1321,8 @@ Second level methods.`;
13141321 it ( 'should handle Function type without subTypedKeys' , ( ) => {
13151322 const result = rawTypeToTypeInformation ( 'Function' , '' , null ) ;
13161323 expect ( result . type ) . toBe ( 'Function' ) ;
1317- expect ( result . parameters ) . toEqual ( [ ] ) ;
1318- expect ( result . returns ) . toBeNull ( ) ;
1324+ expect ( ( result as DetailedFunctionType ) . parameters ) . toEqual ( [ ] ) ;
1325+ expect ( ( result as DetailedFunctionType ) . returns ) . toBeNull ( ) ;
13191326 } ) ;
13201327
13211328 it ( 'should handle Function type with subTypedKeys' , ( ) => {
@@ -1329,16 +1336,16 @@ Second level methods.`;
13291336
13301337 const result = rawTypeToTypeInformation ( 'Function' , '' , typedKeys ) ;
13311338 expect ( result . type ) . toBe ( 'Function' ) ;
1332- expect ( result . parameters ) . toHaveLength ( 2 ) ;
1333- expect ( result . parameters ! [ 0 ] . name ) . toBe ( 'callback' ) ;
1334- expect ( result . parameters ! [ 1 ] . name ) . toBe ( 'event' ) ;
1335- expect ( result . returns ) . toBeNull ( ) ;
1339+ expect ( ( result as DetailedFunctionType ) . parameters ) . toHaveLength ( 2 ) ;
1340+ expect ( ( result as DetailedFunctionType ) . parameters [ 0 ] . name ) . toBe ( 'callback' ) ;
1341+ expect ( ( result as DetailedFunctionType ) . parameters [ 1 ] . name ) . toBe ( 'event' ) ;
1342+ expect ( ( result as DetailedFunctionType ) . returns ) . toBeNull ( ) ;
13361343 } ) ;
13371344
13381345 it ( 'should handle Object type without subTypedKeys' , ( ) => {
13391346 const result = rawTypeToTypeInformation ( 'Object' , '' , null ) ;
13401347 expect ( result . type ) . toBe ( 'Object' ) ;
1341- expect ( result . properties ) . toEqual ( [ ] ) ;
1348+ expect ( ( result as DetailedObjectType ) . properties ) . toEqual ( [ ] ) ;
13421349 } ) ;
13431350
13441351 it ( 'should handle String type with subTypedKeys' , ( ) => {
@@ -1352,15 +1359,15 @@ Second level methods.`;
13521359
13531360 const result = rawTypeToTypeInformation ( 'String' , '' , typedKeys ) ;
13541361 expect ( result . type ) . toBe ( 'String' ) ;
1355- expect ( result . possibleValues ) . toHaveLength ( 2 ) ;
1356- expect ( result . possibleValues ! [ 0 ] . value ) . toBe ( 'option1' ) ;
1362+ expect ( ( result as DetailedStringType ) . possibleValues ) . toHaveLength ( 2 ) ;
1363+ expect ( ( result as DetailedStringType ) . possibleValues ! [ 0 ] . value ) . toBe ( 'option1' ) ;
13571364 } ) ;
13581365
13591366 it ( 'should handle Event<> with inner type' , ( ) => {
13601367 const result = rawTypeToTypeInformation ( 'Event<CustomEvent>' , '' , null ) ;
13611368 expect ( result . type ) . toBe ( 'Event' ) ;
1362- expect ( result . eventPropertiesReference ) . toBeDefined ( ) ;
1363- expect ( result . eventPropertiesReference ! . type ) . toBe ( 'CustomEvent' ) ;
1369+ expect ( ( result as DetailedEventReferenceType ) . eventPropertiesReference ) . toBeDefined ( ) ;
1370+ expect ( ( result as DetailedEventReferenceType ) . eventPropertiesReference . type ) . toBe ( 'CustomEvent' ) ;
13641371 } ) ;
13651372
13661373 it ( 'should throw on Event<> with both inner type and parameter list' , ( ) => {
@@ -1394,15 +1401,15 @@ Second level methods.`;
13941401
13951402 const result = rawTypeToTypeInformation ( 'Event<>' , '' , typedKeys ) ;
13961403 expect ( result . type ) . toBe ( 'Event' ) ;
1397- expect ( result . eventProperties ) . toHaveLength ( 1 ) ;
1398- expect ( result . eventProperties ! [ 0 ] . name ) . toBe ( 'detail' ) ;
1404+ expect ( ( result as DetailedEventType ) . eventProperties ) . toHaveLength ( 1 ) ;
1405+ expect ( ( result as DetailedEventType ) . eventProperties [ 0 ] . name ) . toBe ( 'detail' ) ;
13991406 } ) ;
14001407
14011408 it ( 'should handle Function<> with generic types' , ( ) => {
14021409 const result = rawTypeToTypeInformation ( 'Function<String, Number, Boolean>' , '' , null ) ;
14031410 expect ( result . type ) . toBe ( 'Function' ) ;
1404- expect ( result . parameters ) . toHaveLength ( 2 ) ;
1405- expect ( result . returns ! . type ) . toBe ( 'Boolean' ) ;
1411+ expect ( ( result as DetailedFunctionType ) . parameters ) . toHaveLength ( 2 ) ;
1412+ expect ( ( result as DetailedFunctionType ) . returns ! . type ) . toBe ( 'Boolean' ) ;
14061413 } ) ;
14071414
14081415 it ( 'should handle Function<> without generic params falling back to subTypedKeys' , ( ) => {
@@ -1413,9 +1420,9 @@ Second level methods.`;
14131420
14141421 const result = rawTypeToTypeInformation ( 'Function<Boolean>' , '' , typedKeys ) ;
14151422 expect ( result . type ) . toBe ( 'Function' ) ;
1416- expect ( result . parameters ) . toHaveLength ( 1 ) ;
1417- expect ( result . parameters ! [ 0 ] . name ) . toBe ( 'arg1' ) ;
1418- expect ( result . returns ! . type ) . toBe ( 'Boolean' ) ;
1423+ expect ( ( result as DetailedFunctionType ) . parameters ) . toHaveLength ( 1 ) ;
1424+ expect ( ( result as DetailedFunctionType ) . parameters [ 0 ] . name ) . toBe ( 'arg1' ) ;
1425+ expect ( ( result as DetailedFunctionType ) . returns ! . type ) . toBe ( 'Boolean' ) ;
14191426 } ) ;
14201427
14211428 it ( 'should throw on generic type without inner types' , ( ) => {
@@ -1434,7 +1441,7 @@ Second level methods.`;
14341441 expect ( result . type ) . toBe ( 'Promise' ) ;
14351442 expect ( result . innerTypes ) . toHaveLength ( 1 ) ;
14361443 expect ( result . innerTypes ! [ 0 ] . type ) . toBe ( 'Object' ) ;
1437- expect ( result . innerTypes ! [ 0 ] . properties ) . toHaveLength ( 1 ) ;
1444+ expect ( ( result . innerTypes ! [ 0 ] as DetailedObjectType ) . properties ) . toHaveLength ( 1 ) ;
14381445 } ) ;
14391446 } ) ;
14401447
0 commit comments