@@ -58,7 +58,7 @@ export function createSignature(
58
58
sigRef . parameters = convertParameters (
59
59
context ,
60
60
sigRef ,
61
- signature . parameters ,
61
+ signature . parameters as readonly ( ts . Symbol & { type : ts . Type } ) [ ] ,
62
62
declaration ?. parameters
63
63
) ;
64
64
@@ -84,15 +84,17 @@ export function createSignature(
84
84
function convertParameters (
85
85
context : Context ,
86
86
sigRef : SignatureReflection ,
87
- parameters : readonly ts . Symbol [ ] ,
87
+ parameters : readonly ( ts . Symbol & { type : ts . Type } ) [ ] ,
88
88
parameterNodes : readonly ts . ParameterDeclaration [ ] | undefined
89
89
) {
90
90
return parameters . map ( ( param , i ) => {
91
- const declaration = param . valueDeclaration ;
91
+ const declaration = param . valueDeclaration as
92
+ | ts . Declaration
93
+ | undefined ;
92
94
assert (
93
- declaration &&
94
- ( ts . isParameter ( declaration ) ||
95
- ts . isJSDocParameterTag ( declaration ) )
95
+ ! declaration ||
96
+ ts . isParameter ( declaration ) ||
97
+ ts . isJSDocParameterTag ( declaration )
96
98
) ;
97
99
const paramRefl = new ParameterReflection (
98
100
/ _ _ \d + / . test ( param . name ) ? "__namedParameters" : param . name ,
@@ -108,25 +110,34 @@ function convertParameters(
108
110
109
111
paramRefl . type = context . converter . convertType (
110
112
context . withScope ( paramRefl ) ,
111
- context . checker . getTypeOfSymbolAtLocation ( param , declaration )
113
+ param . type
112
114
) ;
113
115
114
- const isOptional = ts . isParameter ( declaration )
115
- ? ! ! declaration . questionToken
116
- : declaration . isBracketed ;
116
+ let isOptional = false ;
117
+ if ( declaration ) {
118
+ isOptional = ts . isParameter ( declaration )
119
+ ? ! ! declaration . questionToken
120
+ : declaration . isBracketed ;
121
+ }
122
+
117
123
if ( isOptional ) {
118
124
paramRefl . type = removeUndefined ( paramRefl . type ) ;
119
125
}
120
126
121
127
paramRefl . defaultValue = convertDefaultValue ( parameterNodes ?. [ i ] ) ;
122
128
paramRefl . setFlag ( ReflectionFlag . Optional , isOptional ) ;
123
- paramRefl . setFlag (
124
- ReflectionFlag . Rest ,
125
- ts . isParameter ( declaration )
129
+
130
+ // If we have no declaration, then this is an implicitly defined parameter in JS land
131
+ // because the method body uses `arguments`... which is always a rest argument
132
+ let isRest = true ;
133
+ if ( declaration ) {
134
+ isRest = ts . isParameter ( declaration )
126
135
? ! ! declaration . dotDotDotToken
127
136
: ! ! declaration . typeExpression &&
128
- ts . isJSDocVariadicType ( declaration . typeExpression . type )
129
- ) ;
137
+ ts . isJSDocVariadicType ( declaration . typeExpression . type ) ;
138
+ }
139
+
140
+ paramRefl . setFlag ( ReflectionFlag . Rest , isRest ) ;
130
141
return paramRefl ;
131
142
} ) ;
132
143
}
0 commit comments