December 2017
Beginner
372 pages
10h 32m
English
Decorators in TypeScript are just the function definition, so ideally we can just write a TypeScript function and use it as a decorator. The only difference is the type of parameters the decorator accepts. The following is the simplest possible example of a decorator function and how it is used in a class:

On line number two, we define a standard TypeScript function that takes one parameter. The parameter is of type Function in this case. Then we use this decorator on line number seven by just referencing it with its name and prefixed with an @ sign. The @ (at) sign tells TypeScript that this is a decorator ...
Read now
Unlock full access