-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
const
type parameters don't work with mutable array constraints
#51931
Comments
Just pointing out that |
This is working as intended. See the last part of the description here for the rationale. |
Oh, that... it is somewhat unexpected at the first glance but in retrospect, I understand this reasoning. But in such a case - Those two are also interesting but I don't have a clear understanding of what a spread does to a type parameter, so maybe both here are exped. Could you take a look? declare function fn<const T extends any[]>(...args: [...T]): T;
const a = fn("a", false);
// ^? [string, boolean]
declare function fn2<const T extends readonly any[]>(...args: [...T]): T;
const a = fn2("b", true);
// ^? [string, boolean] Should the second one benefit from |
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
const
doesn't work with extends
const
doesn't work mutable array constraints
const
doesn't work mutable array constraintsconst
type parameters don't work with mutable array constraints
Bug Report
I'm not sure if this is intended behavior. If this is not a bug, I'd suggest supporting this as a feature.
π Search Terms
const, args, generic args, extends
π Version & Regression Information
v5.0.0
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
The return type is
any[]
π Expected behavior
The return type should be
["a", false]
The text was updated successfully, but these errors were encountered: