Skip to content

Commit b94b6aa

Browse files
committed
fix(linter/explicit-module-boundary-types): false negative with export default function (#14905)
fixes #14831
1 parent ab16817 commit b94b6aa

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

crates/oxc_linter/src/rules/typescript/explicit_module_boundary_types.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ impl ExplicitModuleBoundaryTypes {
281281
// walk::walk_variable_declarator(&mut checker, it)
282282
}
283283
AstKind::Function(it) => {
284-
walk::walk_function(checker, it, ScopeFlags::Function);
284+
checker.visit_function(it, ScopeFlags::Function);
285285
}
286286
AstKind::Class(it) => walk::walk_class(checker, it),
287287
_ => {}
@@ -1991,6 +1991,7 @@ mod test {
19911991
"function Test(): void { const _x = () => { }; } function Test2() { return () => { }; } export { Test2 };",
19921992
None,
19931993
),
1994+
("function App() { return 42; } export default App", None),
19941995
];
19951996

19961997
Tester::new(

crates/oxc_linter/src/snapshots/typescript_explicit_module_boundary_types.snap

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,14 @@ source: crates/oxc_linter/src/tester.rs
373373
3return arg;
374374
╰────
375375

376+
typescript-eslint(explicit-module-boundary-types): Missing return type on function
377+
╭─[explicit_module_boundary_types.tsx:2:22]
378+
1 │
379+
2 │ function foo(arg) {
380+
· ───
381+
3return arg;
382+
╰────
383+
376384
typescript-eslint(explicit-module-boundary-types): Missing argument type on function
377385
╭─[explicit_module_boundary_types.tsx:2:26]
378386
1 │
@@ -381,6 +389,14 @@ source: crates/oxc_linter/src/tester.rs
381389
3return arg;
382390
╰────
383391

392+
typescript-eslint(explicit-module-boundary-types): Missing return type on function
393+
╭─[explicit_module_boundary_types.tsx:2:22]
394+
1 │
395+
2 │ function foo(arg) {
396+
· ───
397+
3return arg;
398+
╰────
399+
384400
typescript-eslint(explicit-module-boundary-types): Missing argument type on function
385401
╭─[explicit_module_boundary_types.tsx:2:26]
386402
1 │
@@ -389,6 +405,14 @@ source: crates/oxc_linter/src/tester.rs
389405
3return arg;
390406
╰────
391407

408+
typescript-eslint(explicit-module-boundary-types): Missing return type on function
409+
╭─[explicit_module_boundary_types.tsx:2:22]
410+
1 │
411+
2 │ function foo(arg) {
412+
· ───
413+
3return arg;
414+
╰────
415+
392416
typescript-eslint(explicit-module-boundary-types): Missing argument type on function
393417
╭─[explicit_module_boundary_types.tsx:2:38]
394418
1 │
@@ -682,7 +706,13 @@ source: crates/oxc_linter/src/tester.rs
682706
╰────
683707

684708
typescript-eslint(explicit-module-boundary-types): Missing return type on function
685-
╭─[explicit_module_boundary_types.tsx:1:75]
709+
╭─[explicit_module_boundary_types.tsx:1:58]
686710
1 │ function Test(): void { const _x = () => { }; } function Test2() { return () => { }; } export { Test2 };
687-
· ──
711+
· ─────
712+
╰────
713+
714+
typescript-eslint(explicit-module-boundary-types): Missing return type on function
715+
╭─[explicit_module_boundary_types.tsx:1:10]
716+
1 │ function App() { return 42; } export default App
717+
· ───
688718
╰────

0 commit comments

Comments
 (0)