Skip to content

Disallow type predicate as type assertion #5936

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

Closed
wants to merge 4 commits into from

Conversation

sandersn
Copy link
Member

@sandersn sandersn commented Dec 4, 2015

Fixes #5731 by disallowing the construction for now.

@sandersn
Copy link
Member Author

sandersn commented Dec 7, 2015

@weswigham @ahejlsberg could you take a look since you commented on the original issue.

const widenedType = getWidenedType(exprType);
if (produceDiagnostics) {
if (node.type.kind === SyntaxKind.TypePredicate) {
error(node.type, Diagnostics.A_type_predicate_is_not_allowed_as_part_of_a_type_assertion_expression);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than creating a new error message, why not call checkTypePredicate, which aught to error here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I didn't know about that.

@sandersn
Copy link
Member Author

sandersn commented Dec 7, 2015

OK, the change is much smaller now.

@sandersn sandersn closed this Dec 8, 2015
@mhegazy mhegazy deleted the disallow-type-predicate-as-type-assertion branch December 8, 2015 17:46
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants