Make ParameterDecorator and the like generic #42528
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
lib Update Request
Missing / Incorrect Definition
ParameterDecorator is currently not generic, it can be attachted to any parameter. However, when a decorator is used for e.g. Dependency Injection purposes, some decorators require the type of the parameter to be consistent with the type of the decorator
Sample Code
E.g. we want this to work
But this to fail:
(as userId will be a number, not a string so the injection should ideally not be possible (at compile time)
Currently UserId is done more or less this way:
while I'd like to add
number
toParameterDecorator
:and I'd like typescript to check this when applying a decorator.
The text was updated successfully, but these errors were encountered: