Typescript typing constants
Let’s say you are creating a type and you want a property to refer to a specific constant.
a) Declare the constant
const MY_CONST = ‘MY_CONST’;
b) Use typeof to reference the constant.
type CustomType = {type: typeof MY_CONST, otherstuff: any}; Source: https://brudinie.medium.com/feed
Latest posts by ElearningWorld Admin (see all)
- Job offered: Senior Technical Architect / Consultant – 30th June 2026
- ElearningWorld.org is for sale – 23rd June 2026
- Proyecto EdTech Colombia: Plataforma Moodle Gamificada, Escalable y Adaptativa – 18th October 2025

