Issue
For example, how can I get the options parameter of scrollBy() method?
Parameters<Element["scrollTo"]>
only returns [x: number, y: number]
and not options?: ScrollToOptions
scrollTo(options?: ScrollToOptions): void;
scrollTo(x: number, y: number): void;
Solution
Please see this issue and TS docs:
When inferring from a type with multiple call signatures (such as the type of an overloaded function), inferences are made from the last signature (which, presumably, is the most permissive catch-all case). It is not possible to perform overload resolution based on a list of argument types.
Parameters
always returns last call signature
In this case it worth using :
const foo:Element["scrollTo"]=(...args:unknown[])=>{
}
Answered By - captain-yossarian
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.