Texonom
Texonom
/
Engineering
Engineering
/Software Engineering/Programming/Programming Language/Programming Languages/4GL/ECMAScript/Typescript/Typescript Grammar/TypeScript Keyword/
TS keyof keyword
Loading views...
Search

TS keyof keyword

Creator
Creator
Seonglae ChoSeonglae Cho
Created
Created
2021 Jul 15 5:49
Editor
Editor
Seonglae ChoSeonglae Cho
Edited
Edited
2025 Oct 16 12:35
Refs
Refs
TS as keyword
TS Template Literal Type
type Option<T> = { [K in keyof T]?: T[K] }
 

With
TS Template Literal Type

type Getters<Type> = { [Property in keyof Type as `get${Capitalize<string & Property>}`]: () => Type[Property] }; interface Person { name: string; age: number; location: string; } type LazyPerson = Getters<Person>; type LazyPerson = { getName: () => string; getAge: () => number; getLocation: () => string; }
 
 
Documentation - Mapped Types
When you don't want to repeat yourself, sometimes a type needs to be based on another type.
Documentation - Mapped Types
https://www.typescriptlang.org/docs/handbook/2/mapped-types.html
Documentation - Mapped Types
Get keys of a Typescript interface as array of strings
Creating an array or tuple of keys from an interface with safety compile-time checks requires a bit of creativity. Types are erased at run-time and object types (unordered, named) cannot be converted to tuple types (ordered, unnamed) without resorting to non-supported techniques.
Get keys of a Typescript interface as array of strings
https://stackoverflow.com/questions/43909566/get-keys-of-a-typescript-interface-as-array-of-strings
Get keys of a Typescript interface as array of strings
 
 

Recommendations

Texonom
Texonom
/
Engineering
Engineering
/Software Engineering/Programming/Programming Language/Programming Languages/4GL/ECMAScript/Typescript/Typescript Grammar/TypeScript Keyword/
TS keyof keyword
Copyright Seonglae Cho