Skip to content
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

Detect expectError statements in nested blocks #19

Merged

Conversation

BendingBender
Copy link
Collaborator

Currently, expectError detection only checks statements in the outermost layer of a file. This misses all expectError statements that are nested inside of blocks (like if or try) producing false positives during linting.

This PR extends this detection mechanism to walk through the whole syntax tree to find expectError statements.

Copy link
Collaborator

@SamVerschueren SamVerschueren left a comment

Choose a reason for hiding this comment

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

Cool!

Can you just explain in what use cases you would wrap it in something like an if-statement? I think I saw a TypeScript definition passing by with if-statements, but can't recall it anymore.

source/lib/compiler.ts Show resolved Hide resolved
source/lib/compiler.ts Show resolved Hide resolved
@BendingBender
Copy link
Collaborator Author

BendingBender commented Mar 20, 2019

Here's one use case. Another would be for a discriminated union type. For such a type you need an if condition to differentiate between the shapes. Here's the use case for a discriminated union.

@SamVerschueren SamVerschueren merged commit f97d462 into tsdjs:master Mar 20, 2019
@SamVerschueren
Copy link
Collaborator

Thanks 🎉!

@BendingBender BendingBender deleted the walk-node-tree-for-expect-error branch March 20, 2019 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants