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)
- eLearning Developer / Instructional Designer - 28th August 2026
- Senior Moodle Engineer - 20th August 2026
- Job: Freelance Moodle Developer - 21st July 2026

