getter and setter
Special methods that run when a property is read (getter) or assigned (setter), so it looks like a field but runs code.
In more detail
The course generates typed getter names such as getId with mapped types. The accessor keyword on a class field creates a getter, a setter and hidden storage in one step.
Related terms
- auto-accessor — A class field declared with the accessor keyword, which creates a hidden storage slot plus a getter and setter for it automatically.
- mapped type — A type that builds a new object type by looping over a set of keys, such as { [K in keyof T]: T[K] }.
- class — A blueprint in code that bundles data and the functions that work on it, from which objects are made.
Taught in
- Tuples: Fixed Length, Labeled Elements And Variadic Tuples — Production TypeScript
- Generic Constraints: extends, keyof And Indexed Access — Production TypeScript
- Mapped Types, Key Remapping With as And Template Literals — Production TypeScript
- Modern Decorators: Stage 3 Standards And Class Metadata — Production TypeScript