-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
Bug Report
In the current version of TypeScript, decorators which don't use the context do not work properly when noUnusedParameters
is enabled. If the decorator includes a context parameter, then the compiler reports an error on the unused parameter. If the decorator does not include the context parameter, than the decorator cannot be used, as the decorator is called with one too many arguments.
🔎 Search Terms
decorator, decorators
🕗 Version & Regression Information
This changed between versions 4.9 and 5.0
⏯ Playground Link
Playground link with relevant code
💻 Code
function MyDecorator(target: new (...args: never) => unknown) {
console.log(target);
}
@MyDecorator
class MyClass {}
🙁 Actual behavior
Code compiles without errors.
🙂 Expected behavior
TypeScript throws the following error:
Unable to resolve signature of class decorator when called as an expression.
The runtime will invoke the decorator with 2 arguments, but the decorator expects 1.
Jokero, vui611, sibstark, parav01d, lideming and 17 more
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue