mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Error on nodes which should not have type predicates.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user