Give a more helpful error message when users try decorating using expressions that take no arguments.

This commit is contained in:
Daniel Rosenwasser committed 2017-09-27 20:46:42 -07:00
1 parent d407f14e86
commit b029857528
2 files changed
+9

No files matched your search

Regular → Executable
+5
View 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
View 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",