fix(linter/explicit-function-return-type): false negative with HOF detection#20495
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
Pull request overview
Fixes a false negative in the typescript/explicit-function-return-type rule where return statements inside try/catch were incorrectly treated as “higher-order function” returns, causing missing-return-type diagnostics to be skipped.
Changes:
- Reworked higher-order function detection to scan actual
returnstatements across nested control-flow (includingtry/catch) and verify their returned expressions are functions. - Added a new failing test case and updated the snapshot to cover the
try/catchscenario from #20482.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| crates/oxc_linter/src/rules/typescript/explicit_function_return_type.rs | Updates HOF detection by walking return statements via an AST visitor; adds a regression test case. |
| crates/oxc_linter/src/snapshots/typescript_explicit_function_return_type.snap | Updates expected diagnostic snapshot for the new regression case. |
You can also share your feedback on Copilot code review. Take the survey.
c4ffb72 to
995ac4a
Compare
Merge activity
|
995ac4a to
50d59e9
Compare

fixes #20482