@@ -58,7 +58,7 @@ export function createSignature(
5858 sigRef . parameters = convertParameters (
5959 context ,
6060 sigRef ,
61- signature . parameters ,
61+ signature . parameters as readonly ( ts . Symbol & { type : ts . Type } ) [ ] ,
6262 declaration ?. parameters
6363 ) ;
6464
@@ -84,15 +84,17 @@ export function createSignature(
8484function convertParameters (
8585 context : Context ,
8686 sigRef : SignatureReflection ,
87- parameters : readonly ts . Symbol [ ] ,
87+ parameters : readonly ( ts . Symbol & { type : ts . Type } ) [ ] ,
8888 parameterNodes : readonly ts . ParameterDeclaration [ ] | undefined
8989) {
9090 return parameters . map ( ( param , i ) => {
91- const declaration = param . valueDeclaration ;
91+ const declaration = param . valueDeclaration as
92+ | ts . Declaration
93+ | undefined ;
9294 assert (
93- declaration &&
94- ( ts . isParameter ( declaration ) ||
95- ts . isJSDocParameterTag ( declaration ) )
95+ ! declaration ||
96+ ts . isParameter ( declaration ) ||
97+ ts . isJSDocParameterTag ( declaration )
9698 ) ;
9799 const paramRefl = new ParameterReflection (
98100 / _ _ \d + / . test ( param . name ) ? "__namedParameters" : param . name ,
@@ -108,25 +110,34 @@ function convertParameters(
108110
109111 paramRefl . type = context . converter . convertType (
110112 context . withScope ( paramRefl ) ,
111- context . checker . getTypeOfSymbolAtLocation ( param , declaration )
113+ param . type
112114 ) ;
113115
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+
117123 if ( isOptional ) {
118124 paramRefl . type = removeUndefined ( paramRefl . type ) ;
119125 }
120126
121127 paramRefl . defaultValue = convertDefaultValue ( parameterNodes ?. [ i ] ) ;
122128 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 )
126135 ? ! ! declaration . dotDotDotToken
127136 : ! ! declaration . typeExpression &&
128- ts . isJSDocVariadicType ( declaration . typeExpression . type )
129- ) ;
137+ ts . isJSDocVariadicType ( declaration . typeExpression . type ) ;
138+ }
139+
140+ paramRefl . setFlag ( ReflectionFlag . Rest , isRest ) ;
130141 return paramRefl ;
131142 } ) ;
132143}
0 commit comments