chan.dev / posts

TypeScript Lookup Types

🌱 This post is in the growth phase. It may still be useful as it grows up.

type Post = {
title: string
publishDate: Date
tags: string[]
}
let tags = ["Barbie", "Ken", "Alan"]: Post["tags"];
let tag = "test": Post["tags"][0];
tags; // string[]
tag; // string