Skip to content

Conversation

yokomotod
Copy link

Fixes #36775

=== tests/cases/compiler/catchClauseWithUnknownTypeAnnotation.ts ===
try {
} catch (e: unknown) {
>e : any
Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Author

Choose a reason for hiding this comment

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

@ajafff I've fixed.

@yokomotod
Copy link
Author

also added a commit to address type alias case.

@sandersn sandersn added For Backlog Bug PRs that fix a backlog bug Experiment A fork with an experimental idea which might not make it into master and removed For Backlog Bug PRs that fix a backlog bug labels Feb 26, 2020
// Grammar checking
if (catchClause.variableDeclaration) {
if (catchClause.variableDeclaration.type) {
if (catchClause.variableDeclaration.type && tryGetTypeFromEffectiveTypeNode(catchClause.variableDeclaration) !== unknownType) {
Copy link
Contributor

Choose a reason for hiding this comment

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

See #36775 (comment)

Suggested change
if (catchClause.variableDeclaration.type && tryGetTypeFromEffectiveTypeNode(catchClause.variableDeclaration) !== unknownType) {
if (catchClause.variableDeclaration.type && tryGetTypeFromEffectiveTypeNode(catchClause.variableDeclaration) !== anyType && tryGetTypeFromEffectiveTypeNode(catchClause.variableDeclaration) !== unknownType) {

@RyanCavanaugh
Copy link
Member

Closing in favor of #39015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Experiment A fork with an experimental idea which might not make it into master
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow unknown type annotation on catch clause variable
5 participants