The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.
#required parameter based on type parameter value
1 messages · Page 1 of 1 (latest)
@green lynx Here's a shortened URL of your playground link! You can remove the full link from your message.
The never type does not mean a parameter is optional
If you want to mark a parameter as optional, use ?
function foo(bar?: number) {
}
what I want is that if the type parameter is some type, the function accepts 0 arguments
Or use overloads for more complex signatures
You cannot make a check on a parameter you are not passing
how would the function overload would look like for my needs?
(please see playground)
got it working with rest parameters
!hb overload
Declaration Files / Declaration Reference