You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typeNoBoolean<K,T>=Textendsboolean ? never : KtypeFilterBooleans<T>={[KinkeyofTasNoBoolean<K,T[K]>]: T[K]}typeFiltered=FilterBooleans<[string,boolean,number,boolean]>// should only accept ["1", 3]constf: Filtered=["1",true,3,false]typeLength=Filtered["length"];// should only accept 2, not 4constl: Length=4;
π Actual behavior
#26063 introduced mapped type support for arrays and tuples. This breaks when using the new "key remapping" feature added to TypeScript 4.1. A record type is produced that looks like a tuple, rather than the tuple type that would be produced when not using as to remap keys.
π Expected behavior
A filtered tuple type should be produced.
The text was updated successfully, but these errors were encountered:
I have the same issue here as there: even if you could manage to preserve a tuple type upon key renaming, I donβt see how youβd get a shortened tuple from it. It would be a sparse tuple, if anything. In your mapping, the key "2" would stay "2", right?
@jcalz Thanks for the info. Getting a sparse tuple wouldn't be good for many use cases I think, not unless there was a way to compact it. Filtering an array is possible but not without lots of CPU and a size limit π
Bug Report
π Search Terms
key remapping tuples mapped types
π Version & Regression Information
Typescript 4.1
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
#26063 introduced mapped type support for arrays and tuples. This breaks when using the new "key remapping" feature added to TypeScript
4.1
. Arecord
type is produced that looks like atuple
, rather than thetuple
type that would be produced when not usingas
to remap keys.π Expected behavior
A filtered tuple type should be produced.
The text was updated successfully, but these errors were encountered: