Added test and adjusted reporting logic.

This commit is contained in:
Daniel Rosenwasser
2017-09-29 22:01:00 -07:00
parent 08ef6e4bea
commit 86315ed411
4 changed files with 77 additions and 2 deletions

View File

@@ -16382,7 +16382,7 @@ namespace ts {
}
if (isPotentiallyUncalledDecorator(node, callSignatures)) {
error(node, Diagnostics.This_function_cannot_be_used_as_a_decorator_Did_you_mean_to_call_it_first);
error(node, Diagnostics.This_value_has_type_0_which_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first, typeToString(funcType));
return resolveErrorCall(node);
}
@@ -16406,6 +16406,7 @@ namespace ts {
function isPotentiallyUncalledDecorator(decorator: Decorator, signatures: Signature[]) {
return signatures.length && every(signatures, signature =>
signature.minArgumentCount === 0 &&
!signature.hasRestParameter &&
signature.parameters.length < getEffectiveArgumentCount(decorator, /*args*/ undefined, signature));
}

View File

@@ -907,7 +907,7 @@
"category": "Error",
"code": 1328
},
"This function cannot be used as a decorator. Did you mean to call it first?": {
"This value has type '{0}' which accepts too few arguments to be used as a decorator here. Did you mean to call it first?": {
"category": "Error",
"code": 1329
},

0
src/compiler/emitter.ts Executable file → Normal file
View File