NestJS · Middle · Question 75 of 75
What does @Optional() on a constructor parameter do?
- 1It makes the provider lazy
- ✓Correct answer: If no provider is registered for the token, Nest injects
undefinedinstead of failing - 3It marks the parameter as a query parameter
Explanation
Useful for optional integrations, e.g. a module that works with or without a configured metrics client.