Skip to content

Commit a3aec6a

Browse files
committed
fix(linter/explicit-module-boundary-types): debug assertion fail with top level return (oxc-project#12820)
we parse with: https://github.com/oxc-project/oxc/blob/45206ddcda15bb3e41af5ad3d6e1174f35fe1df0/crates/oxc_linter/src/service/runtime.rs#L945 so it is possible the fns stack is empty fixes oxc-project#12817
1 parent 6efe457 commit a3aec6a

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,6 @@ impl<'a> Visit<'a> for ExplicitTypesChecker<'a, '_> {
476476
AstKind::ArrowFunctionExpression(arrow) => self.fns.push(Fn::Arrow(arrow)),
477477
AstKind::Class(_) => self.fns.push(Fn::None),
478478
AstKind::ReturnStatement(ret) => {
479-
// returns outside of functions are semantic errors
480-
let src: &str = self.ctx.source_text();
481-
debug_assert!(!self.fns.is_empty(), "{src}");
482479
let Some(f) = self.fns.last() else {
483480
return;
484481
};
@@ -1488,6 +1485,7 @@ mod test {
14881485
"function ErrorTrackingRules(): JSX.Element { return (<BindLogic><DndContext onDragEnd={({ active, over }) => { /**/ }}></DndContext></BindLogic>); }; export default ErrorTrackingRules;",
14891486
None,
14901487
),
1488+
("export namespace B{return}", None),
14911489
];
14921490

14931491
let fail = vec![

0 commit comments

Comments
 (0)