Skip to content

fix(no-unnecessary-type-assertion): handle JSDoc autofix ranges#781

Merged
camc314 merged 2 commits intooxc-project:mainfrom
jkker:fix/jsdoc-parenthesized-assertion-panic
Mar 10, 2026
Merged

fix(no-unnecessary-type-assertion): handle JSDoc autofix ranges#781
camc314 merged 2 commits intooxc-project:mainfrom
jkker:fix/jsdoc-parenthesized-assertion-panic

Conversation

@jkker
Copy link
Copy Markdown
Contributor

@jkker jkker commented Mar 10, 2026

Summary

  • detect JSDoc-backed type assertions by scanning the trivia before the asserted expression instead of assuming as token ordering
  • remove the JSDoc cast and trailing whitespace without touching the parenthesized expression, which avoids the inverted slice panic from issue panic in no-unnecessary-type-assertion autofix for JSDoc cast on parenthesized expression #780
  • add a regression test that exercises a checked JavaScript file with /** @type {string} */ (s) and verifies the autofix output

Testing

  • go test ./internal/rules/no_unnecessary_type_assertion/...
  • reproduced the original crash with tsgolint headless --fix before the patch; verified it exits cleanly after the patch

Closes #780
Refs typescript-eslint/tsgolint#5

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@camc314 camc314 force-pushed the fix/jsdoc-parenthesized-assertion-panic branch from 04c8d73 to 6d82e82 Compare March 10, 2026 19:52
Copy link
Copy Markdown
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

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

thank you!

@camc314 camc314 merged commit 410983c into oxc-project:main Mar 10, 2026
7 checks passed
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.

panic in no-unnecessary-type-assertion autofix for JSDoc cast on parenthesized expression

3 participants