Set value with parameter decorator

89 Views Asked by At

I'm trying to create a Parameter Decorators but i don't get it.
What i want is to have a function with a decorator who define my variable value

class A {
public hello(@helloWorld() hey: string){
  console.log(hey) // should be equal to "Hello World"
 }
}

I would like to use it in my api so I can inject the context of my incoming request in this scope.

What is typescript documentation is saying:

NOTE: A parameter decorator can only be used to observe that a parameter has been declared on a method.

Typescript doc
But I saw nestJs done this with the @Body() and when looking the source code I still don't get It. They never return a value they work with Reflect

0

There are 0 best solutions below