escalier-lang / escalier-next

Improved type safety with tight TypeScript interop
https://escalier-lang.github.io/escalier-next/
MIT License
14 stars 0 forks source link

Special handling when applying mapped types to array and tuple types #325

Open kevinbarabash opened 3 months ago

kevinbarabash commented 3 months ago

We want the following behaviour:

type A = [number, string];
type B = A[number];

type Foo<T> = {
   [K in keyof T]: T[K][]
};

type X = Foo<A>; // [number[], string[]]
type Y = Foo<number[]>; // number[][]

Right now Escalier produces the following types:

type X = Foo<A>: // {0: string[], 1: number[]}
type Y = Foo<number[]>; // {[K]: string[] for K in number}