@@ -19,6 +19,7 @@ interface typeDataType {
19
19
target : number ;
20
20
name : string ;
21
21
} ;
22
+ signatures ?: number [ ] ;
22
23
}
23
24
interface ParameterComponentType {
24
25
typeData : typeDataType ;
@@ -33,6 +34,9 @@ export const ParameterType = ({ typeData }: ParameterComponentType) => {
33
34
if ( typeData . kind === 256 ) {
34
35
typeType = 'declaration' ;
35
36
}
37
+ if ( typeData . kind === 2048 ) {
38
+ typeType = 'function' ;
39
+ }
36
40
37
41
// adds type arguments to an array to be rendered
38
42
const addTypeArgs = (
@@ -84,6 +88,12 @@ export const ParameterType = ({ typeData }: ParameterComponentType) => {
84
88
return typeData . name ;
85
89
case 'array' :
86
90
return < ArrayType data = { typeData . elementType } /> ;
91
+ case 'function' :
92
+ let functionSig ;
93
+ if ( typeData ?. signatures ) {
94
+ functionSig = references [ typeData . signatures [ 0 ] ] ;
95
+ }
96
+ return < FunctionType data = { functionSig } /> ;
87
97
default :
88
98
if ( typeof typeType === 'object' && typeType !== null ) {
89
99
return < ParameterType typeData = { typeType } /> ;
@@ -93,8 +103,6 @@ export const ParameterType = ({ typeData }: ParameterComponentType) => {
93
103
} ;
94
104
95
105
const ArrayType = ( { data } ) => {
96
- console . log ( 'ARRAY TYPE' ) ;
97
- console . log ( data ) ;
98
106
return (
99
107
< >
100
108
< ParameterType typeData = { data } />
@@ -103,6 +111,27 @@ const ArrayType = ({ data }) => {
103
111
) ;
104
112
} ;
105
113
114
+ const FunctionType = ( { data } ) => {
115
+ if ( ! data ) return 'Function' ;
116
+ const functionTypeArray : ( string | React . JSX . Element ) [ ] = [ '(' ] ;
117
+ if ( data . parameters ) {
118
+ data . parameters . forEach ( ( paramId , idx ) => {
119
+ if ( idx !== 0 ) {
120
+ functionTypeArray . push ( ', ' ) ;
121
+ }
122
+ const param = references [ paramId ] ;
123
+ functionTypeArray . push (
124
+ < ParameterType typeData = { param } key = { param . name } />
125
+ ) ;
126
+ } ) ;
127
+ }
128
+ functionTypeArray . push ( ') => ' ) ;
129
+ functionTypeArray . push (
130
+ < ParameterType typeData = { data . type } key = { data . type . name } />
131
+ ) ;
132
+ return functionTypeArray ;
133
+ } ;
134
+
106
135
const ReferenceType = ( { data } ) => {
107
136
// should be a link that loads the next type when clicked on
108
137
const referencedObject = references [ data . target ] ;
0 commit comments