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

🐛 complexity/useLiteralKeys emits invalid AST #266

Closed
1 task done
ematipico opened this issue Sep 13, 2023 · 0 comments · Fixed by #269
Closed
1 task done

🐛 complexity/useLiteralKeys emits invalid AST #266

ematipico opened this issue Sep 13, 2023 · 0 comments · Fixed by #269
Assignees
Labels
A-Linter Area: linter S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@ematipico
Copy link
Member

ematipico commented Sep 13, 2023

Environment information

main

What happened?

Have this code:

if (typeof window !== 'undefined' && Boolean(window)) {
	((window as unknown) as Record<string, unknown>)['optimizelyService'] = optimizelyService;
}

const IS_RUNNING_IN_CYPRESS =
	typeof window === 'undefined' ? false : Boolean((window as never)?.['Cypress']);

Then run biome check --apply-unsafe ./file.js and you'll get

../test.ts internalError/panic  INTERNAL  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ✖ processing panicked: Tried to cast node with kind JS_STATIC_MEMBER_EXPRESSION as `"biome_js_syntax::generated::nodes::AnyJsAssignmentPattern"` but was unable to cast
  
  ⚠ This diagnostic was derived from an internal Biome error. Potential bug, please report it if necessary.

If you disable the rule, the unsafe fixes are correctly applied and the process doesn't panic

Related to #98

Expected result

The rule should emit a valid AST

Code of Conduct

  • I agree to follow Biome's Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Area: linter S-Bug-confirmed Status: report has been confirmed as a valid bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant