DEV Community

TypeScript method decorators example

Simon Cleriot on March 25, 2018

Decorators are a stage 2 proposal for JavaScript already available as an experimental feature in TypeScript. A decorator is a function that applie...
Collapse
 
17cupsofcoffee profile image
Joe Clay

This was a nice introduction to the new syntax! Really excited for decorators to finally become part of the JS spec (hopefully) soon.

One note - I believe you only need the emitDecoratorMetadata option if you want to use TypeScript's reflection API, which isn't currently part of the stage 2 proposal. For the examples you gave, I think turning on experimentalDecorators is all you need :)

Collapse
 
scleriot profile image
Simon Cleriot

You're absolutely right, I copied/pasted that config from one of my project. I'll update the article ;)