-
-
Notifications
You must be signed in to change notification settings - Fork 580
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
Add ArrayAt
type for stricter Array.prototype.at()
with tuples
#369
Comments
PR welcome |
Per discussion in sindresorhus/ts-extras#39, should this be |
If we call this type |
Why would you use it with non-tuples? It has no benefit. |
I'm thinking of cases where users might have a type param for an array or a tuple which is passed to this type. Might be good to gracefully handle those. Not sure if this would be an actual pain point though. |
Then I suggest we do two types:
|
What would the behavior of |
|
For arrays I would expect
|
@sindresorhus But what if we have an array type type T = number[] | [true, false];
type X = ArrayAt<T, -1>; // Should be `number | false`, IMO |
See sindresorhus/ts-extras#39 and microsoft/TypeScript#47660.
Upvote & Fund
The text was updated successfully, but these errors were encountered: