What version of Oxlint are you using?
main (72d62a1)
What command did you run?
I reproduced this with the rule's expect_fix test harness on main (cargo test -p oxc_linter --lib -- prefer_function_type). The CLI equivalent is oxlint --fix -A all -D typescript/prefer-function-type.
What does your .oxlintrc.json config file look like?
No config file.
What happened?
When the call or construct signature is followed by a comma instead of a semicolon, the typescript/prefer-function-type fix keeps the comma, and the output does not parse:
| Input |
Fixed output |
interface Foo { (): string, } |
type Foo = () => string,; |
type Foo = { (): void, } |
type Foo = () => void, |
let x: { (): void, }; |
let x: () => void,; |
The diagnostic help text also shows the stray comma, for example () => string,.
The cause is in check_member in crates/oxc_linter/src/rules/typescript/prefer_function_type.rs. The parser (parse_type_member_semicolon) includes the member separator, either , or ;, in the signature span. The rule only strips a trailing ;.
I have a fix with regression tests and will open a PR.
(AI-assisted: I used Claude Code while investigating; I reproduced and verified this myself.)
What version of Oxlint are you using?
main (72d62a1)
What command did you run?
I reproduced this with the rule's
expect_fixtest harness on main (cargo test -p oxc_linter --lib -- prefer_function_type). The CLI equivalent isoxlint --fix -A all -D typescript/prefer-function-type.What does your
.oxlintrc.jsonconfig file look like?No config file.
What happened?
When the call or construct signature is followed by a comma instead of a semicolon, the
typescript/prefer-function-typefix keeps the comma, and the output does not parse:interface Foo { (): string, }type Foo = () => string,;type Foo = { (): void, }type Foo = () => void,let x: { (): void, };let x: () => void,;The diagnostic help text also shows the stray comma, for example
() => string,.The cause is in
check_memberincrates/oxc_linter/src/rules/typescript/prefer_function_type.rs. The parser (parse_type_member_semicolon) includes the member separator, either,or;, in the signature span. The rule only strips a trailing;.I have a fix with regression tests and will open a PR.
(AI-assisted: I used Claude Code while investigating; I reproduced and verified this myself.)