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

Bug: Program body element type exception #8888

Open
4 tasks done
loynoir opened this issue Apr 9, 2024 · 2 comments · May be fixed by #8892
Open
4 tasks done

Bug: Program body element type exception #8888

loynoir opened this issue Apr 9, 2024 · 2 comments · May be fixed by #8892
Labels
accepting prs Go ahead, send a pull request that resolves this issue AST PRs and Issues about the AST structure bug Something isn't working package: ast-spec Issues related to @typescript-eslint/ast-spec

Comments

@loynoir
Copy link

loynoir commented Apr 9, 2024

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Relevant Package

ast-spec

Playground Link

No response

Repro Code

// `rule.test.ts` input code
function a() { return 42 }; export {a}

ESLint Config

module.exports = {
  parser: "@typescript-eslint/parser",
  rules: {
    "@typescript-eslint/<rule-name>": ["error", ...<options>],
  },
};

tsconfig

{
  "compilerOptions": {
    // ...
  }
}

Expected Result

Remove // @ts-expect-error: workaround for wrong type

Actual Result

rule.ts

        Program(node): void {
          node.body.forEach((el) => {
            switch (el.type) {
              // @ts-expect-error: workaround for wrong type
              case AST_NODE_TYPES.EmptyStatement:
                console.error('BUG: types error means code will not reached, but code actaully reached')
                break
            }
          })

run rule.test.ts

BUG: types error means code will not reached, but code actaully reached

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin ^7.6.0
@typescript-eslint/parser ^7.6.0
@typescript-eslint/rule-tester ^7.6.0
@typescript-eslint/scope-manager ^7.6.0
@typescript-eslint/typescript-estree ^7.6.0
@typescript-eslint/type-utils ^7.6.0
@typescript-eslint/utils ^7.6.0
TypeScript ^5.4.4
ESLint ^8.57.0
node v21.7.1
@loynoir loynoir added bug Something isn't working triage Waiting for maintainers to take a look labels Apr 9, 2024
@auvred
Copy link
Member

auvred commented Apr 9, 2024

@abrahamguo abrahamguo linked a pull request Apr 10, 2024 that will close this issue
3 tasks
@kirkwaiblinger
Copy link
Member

@auvred based on your comment, should this be "accepting prs"?

@bradzacher bradzacher added AST PRs and Issues about the AST structure accepting prs Go ahead, send a pull request that resolves this issue package: ast-spec Issues related to @typescript-eslint/ast-spec and removed triage Waiting for maintainers to take a look labels May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepting prs Go ahead, send a pull request that resolves this issue AST PRs and Issues about the AST structure bug Something isn't working package: ast-spec Issues related to @typescript-eslint/ast-spec
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants