-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Allow unknown type annotation on catch clause variable #36776
Allow unknown type annotation on catch clause variable #36776
Conversation
=== tests/cases/compiler/catchClauseWithUnknownTypeAnnotation.ts === | ||
try { | ||
} catch (e: unknown) { | ||
>e : any |
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.
Seems like the type annotation is not working as expected.
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.
Ohh, overlooked. I'll check.
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.
@ajafff I've fixed.
also added a commit to address type alias case. |
@@ -32140,7 +32140,7 @@ namespace ts { | |||
if (catchClause) { | |||
// Grammar checking | |||
if (catchClause.variableDeclaration) { | |||
if (catchClause.variableDeclaration.type) { | |||
if (catchClause.variableDeclaration.type && tryGetTypeFromEffectiveTypeNode(catchClause.variableDeclaration) !== unknownType) { |
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.
See #36775 (comment)
if (catchClause.variableDeclaration.type && tryGetTypeFromEffectiveTypeNode(catchClause.variableDeclaration) !== unknownType) { | |
if (catchClause.variableDeclaration.type && tryGetTypeFromEffectiveTypeNode(catchClause.variableDeclaration) !== anyType && tryGetTypeFromEffectiveTypeNode(catchClause.variableDeclaration) !== unknownType) { |
Closing in favor of #39015 |
Fixes #36775