Error on nodes which should not have type predicates.

This commit is contained in:
Daniel Rosenwasser 2016-01-28 17:23:56 -08:00
parent cf13a71af4
commit 7c7e2aa032
2 changed files with 8 additions and 1 deletions

View File

@ -11563,11 +11563,14 @@ namespace ts {
return -1;
}
function checkTypePredicate(node: TypePredicateNode) {
function checkTypePredicate(node: TypePredicateNode): void {
const parent = getTypePredicateParent(node);
if (!parent) {
// The parent must not be valid.
error(node.parent, Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods);
return;
}
const typePredicate = getSignatureFromDeclaration(parent).typePredicate;
if (!typePredicate) {
return;

View File

@ -723,6 +723,10 @@
"category": "Error",
"code": 1227
},
"A type predicate is only allowed in return type position for functions and methods.": {
"category": "Error",
"code": 1228
},
"A type predicate cannot reference a rest parameter.": {
"category": "Error",
"code": 1229