samhh/tshm

Mapped types "as" clause

Closed this issue · 2 comments

samhh commented

https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#key-remapping-via-as

Worth checking if this actually makes it into declaration files. Edit: Yes, it does.

samhh commented

This feature will intersect with #15, but that's not a prerequisite. Example:

type Ageless<A> = {
    [K in keyof A as Exclude<K, 'age'>]: A[K]
}

type Person = {
    name: string;
    age: number;
    location: string;
}

type ImmortalPerson = Ageless<Person>