-
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
Key in mapped variadic tuple should not be literal after the variadic part #48856
Comments
I don't think this is a bug. Consider: type Box<T> = { value: T };
type Boxified<T> = { [P in keyof T]: Box<T[P]> };
type T0 = Boxified<[number, string, ...boolean[]]>; // [Box<number>, Box<string>, ...Box<boolean>[]] With the proposed change, |
I also thought about that. The problem is it's really hard to be correct for both the key type itself, and for homomorphic mapped types to continue be homomorphic. However, accessing export type Entries<O extends unknown[]> = { [K in keyof O]: [K, O[K]] }; In an ideal world, I'd like If we have subtracted types, the index should rather by |
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
@Josh-Cena FWIW, I now agree with your observations and suggested changes. See #57031. Better late than never! π |
Bug Report
π Search Terms
Variadic tuple mapped type keyof
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
A
andB
both have the variadic part typed as..."1"[]
, which is wrong.B
is further wrong because thenumber
part becomes"2"
, while in practice it would rarely be"2"
.π Expected behavior
A
should be["0", ...number[]]
;B
should be["0", ...number[], number]
The text was updated successfully, but these errors were encountered: