Typescript Decorators in Examples
Published in
7 min readNov 21, 2020
Let’s take a look at the Typescript Decorators that provide a way to add both annotations and a meta-programming syntax for class declarations and members.
⚠️ NOTE Decorators are an experimental feature that may change in future releases.
What will be covered in this article:
- Prerequisites
- What is Decorator
- Simple examples
- Decorators in depth
1. Prerequisites
Before we start exploring Typescript Decorator examples, I’ll be using an empty Node.js typescript project with no additional packages, lints, etc.
All we will need is a typescript
in our dev dependencies in the package.json
file:
First, create an empty folder: