-
Notifications
You must be signed in to change notification settings - Fork 12.8k
[5.1.0-dev.20230413] never
function parameters will reject function call with no type parameters
#53770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm a little bit confused by the phrasing of actual/expected results here. It reads to me that you want to create a function type that is not callable (no function arguments allowed) - and that's exactly the behavior that you get with I feel like I'm misreading the intention here and I would appreciate if you could rephrase. Based on the observed change and the fact that you noticed this... I assume that you want to write a type in 5.1 with the 5.0 behavior~ and that your intention is to "remove" the parameter from the signature. You could do it like this: type OriginalParams<T> = [T] extends [never]
? []
: T extends undefined
? [BaseParams?]
: [BaseParams & T]; |
This code is doing exactly what you told it to do. 3.9 through 5.0 had a bug. See #48840 (comment) |
Yep that works. Not obvious to me why |
It's because Wrapping |
I don't think this is useful to 99.99% of TypeScript users but y'all seem to be fine with this. |
Distributive behavior in conditional types is very useful and people use it all the time. |
Bug Report
π Search Terms
never
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
never
as a type for function parameters not usable to indicate "no arguments allowed"π Expected behavior
Some way to produce a type that results in no function arguments allowed. We used to do this with
FunctionParams<never>
but now it's no longer clear how to do it sinceAnyGenery<never>
already producednever
in TS 5.0The text was updated successfully, but these errors were encountered: