Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 18095

Set value with parameter decorator

$
0
0

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

function(@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 saying:

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

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


Viewing all articles
Browse latest Browse all 18095

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>