diff --git a/crates/oxc_linter/src/rules/typescript/prefer_function_type.rs b/crates/oxc_linter/src/rules/typescript/prefer_function_type.rs index 485b0094c..3ab61df59 100644 --- a/crates/oxc_linter/src/rules/typescript/prefer_function_type.rs +++ b/crates/oxc_linter/src/rules/typescript/prefer_function_type.rs @@ -206,8 +206,10 @@ fn check_member(member: &TSSignature, node: &AstNode<'_>, ctx: &LintContext<'_>) Fix::new( format!( - "type {} = {};", - &interface_decl.id.name, &suggestion + "{} {} = {};", + if is_parent_exported { "export type" } else { "type" }, + &interface_decl.id.name, + &suggestion ), Span::new(node_start, node_end), ) @@ -718,6 +720,11 @@ type X = {} & (() => void); ", None, ), + ( + "export interface AnyFn { (...args: any[]): any }", + "export type AnyFn = (...args: any[]) => any;", + None, + ), ]; Tester::new(PreferFunctionType::NAME, pass, fail).expect_fix(fix).test_and_snapshot();