-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove notion of predicates as types, move predicates back to signatures #6744
Conversation
…rty/get type guards.
…an anything else.
Ping. |
@@ -7092,6 +7082,7 @@ namespace ts { | |||
case SyntaxKind.Identifier: | |||
case SyntaxKind.PropertyAccessExpression: | |||
case SyntaxKind.QualifiedName: | |||
// TODO (drosen): Why a qualified name? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may not be needed - I believe it was just for completeness, since EntityName
(which is what the function on the following line takes) is Identifier | QualifiedName
- provided I'm remembering that right.
It may very well be that the grammar prohibits a QualifiedName
from being passed to this check.
Ping. |
👍 |
LGTM, except I'll probably move changing of error spans for accessor to another PR. This is definitely useful but brings to much noise in tests into this PR |
if (source.kind !== target.kind) { | ||
if (reportErrors) { | ||
errorReporter(Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); | ||
errorReporter(Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not specific to this PR, but error messages refer to this sometimes as "type guards" and others as "type predicate"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point I'll file an issue
+1 for Vlads comment. |
otherwise looks good 👍 |
👍 |
Remove notion of predicates as types, move predicates back to signatures
Fixes #6311.
This is an alternative approach to #6328.
Offline discussions have determined that there was not enough review around the idea of type predicates on accessors and properties. This moves them back to signatures, keeps
this
-based predicates, and continues to infer from type predicates.@mhegazy