Skip to content

Instantly share code, notes, and snippets.

@Roaders
Roaders / TupleToRecord.ts
Last active February 21, 2021 15:00
An example of how to map a Tuple to a record.
type Tuple = [
{name: "one", type?: number},
{name: "two", type: number},
{name: "three", type: number[]}
];
type RecordFromTuple = {
[P in Tuple[number] as P["name"]]: P["type"]
}
@Roaders
Roaders / keyOfTypes.ts
Created January 14, 2020 07:09
Typescript keyof for properties or functions
interface IAddress{
street: string | string[];
town: string;
postcode: string;
}
interface IPerson {
id: number;
name: string;
isFemale: boolean;