mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 02:18:37 -05:00
Give a more helpful error message when users try decorating using expressions that take no arguments.
This commit is contained in:
5
src/compiler/checker.ts
Normal file → Executable file
5
src/compiler/checker.ts
Normal file → Executable file
@@ -16381,6 +16381,11 @@ namespace ts {
|
||||
return resolveUntypedCall(node);
|
||||
}
|
||||
|
||||
if (callSignatures.length === 1 && callSignatures[0].parameters.length === 0) {
|
||||
error(node, Diagnostics.A_decorator_function_must_accept_some_number_of_arguments_but_this_expression_takes_none_Did_you_mean_to_call_it_first);
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
|
||||
const headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
|
||||
if (!callSignatures.length) {
|
||||
let errorInfo: DiagnosticMessageChain;
|
||||
|
||||
4
src/compiler/diagnosticMessages.json
Normal file → Executable file
4
src/compiler/diagnosticMessages.json
Normal file → Executable file
@@ -907,6 +907,10 @@
|
||||
"category": "Error",
|
||||
"code": 1328
|
||||
},
|
||||
"A decorator function must accept some number of arguments, but this expression takes none. Did you mean to call it first?": {
|
||||
"category": "Error",
|
||||
"code": 1329
|
||||
},
|
||||
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
|
||||
Reference in New Issue
Block a user