Markus
Markus

Reputation: 4242

How do Decorators for Configuration/Route Mapping work (TypeScript & Loopback4)?

In Loopback4 REST Endpoints/Operations like "GET /greet" are mapped/configured with a Decorator above the method that processes the query and returns the result:

 @get('/greet', spec)
  greet(name: string) {return "hello"}

I am completely new to Loopback and Typescript. My question is how do such configuration Decorators work in general (also in other frameworks)?

Some Detailed Questions:

Thanks very much!

Upvotes: 1

Views: 95

Answers (1)

Josh Wulf
Josh Wulf

Reputation: 4877

They are evaluated at build-time and require the experimentalDecorators: true setting in tsconfig.json to enable them.

The TypeScript docs cover them well here: https://www.typescriptlang.org/docs/handbook/decorators.html

Upvotes: 1

Related Questions