mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-12 04:17:34 -06:00
Error on nodes which should not have type predicates.
This commit is contained in:
parent
cf13a71af4
commit
7c7e2aa032
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user