@@ -513,6 +513,23 @@ impl<'a> Visit<'a> for ExplicitTypesChecker<'a, '_> {
513513 }
514514 }
515515
516+ fn visit_statements ( & mut self , it : & oxc_allocator:: Vec < ' a , Statement < ' a > > ) {
517+ for stmt in it {
518+ match stmt {
519+ Statement :: ReturnStatement ( _) => {
520+ self . visit_statement ( stmt) ;
521+ }
522+ // Only process expression statements when they are the sole statement in the block.
523+ // This is typically to handle cases like concise arrow functions or modules with a single expression.
524+ // If this logic needs to be expanded to handle more cases, revisit this condition.
525+ Statement :: ExpressionStatement ( _) if it. len ( ) == 1 => {
526+ self . visit_statement ( stmt) ;
527+ }
528+ _ => { }
529+ }
530+ }
531+ }
532+
516533 fn visit_variable_declarator ( & mut self , var : & VariableDeclarator < ' a > ) {
517534 if self . rule . allow_typed_function_expressions && var. id . type_annotation . is_some ( ) {
518535 return ;
@@ -1486,6 +1503,11 @@ mod test {
14861503 None ,
14871504 ) ,
14881505 ( "export namespace B{return}" , None ) ,
1506+ ( "function Test(): void { const _x = () => {}; } export default Test;" , None ) ,
1507+ (
1508+ "function Test(): void { const _x = () => { }; } function Test2() { return (): void => { }; } export { Test2 };" ,
1509+ None ,
1510+ ) ,
14891511 ] ;
14901512
14911513 let fail = vec ! [
@@ -1965,6 +1987,10 @@ mod test {
19651987 " ,
19661988 None ,
19671989 ) ,
1990+ (
1991+ "function Test(): void { const _x = () => { }; } function Test2() { return () => { }; } export { Test2 };" ,
1992+ None ,
1993+ ) ,
19681994 ] ;
19691995
19701996 Tester :: new (
0 commit comments