typeof can turn a value into a type. With as const, a tuple keeps literal elements, so typeof FIELDS[number] becomes a union of those literals. Combine this with indexed access to express a precise Pick<...>.
const KEYS = ["id", "title"] as const;
// typeof KEYS[number] is 'id' | 'title'Use this to build a small preview object from a bigger record.
Build a preview object using keys from a const tuple.
const ARTICLE_FIELDS = ['id', 'title'] as const.type Article = { id: string; title: string; body: string; views: number }.pickArticlePreview(a: Article): Pick<Article, typeof ARTICLE_FIELDS[number]>.id and title.