Skip to content

Commit

Permalink
fix: handle arrow functions with literal return type
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Mar 27, 2023
1 parent cc693ff commit 4d8453b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/loader/babel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ const babelPluginUntyped: PluginItem = function (api: ConfigAPI) {
const newDeclaration = t.functionDeclaration(
declaration.id,
declaration.init.params,
declaration.init.body as t.BlockStatement
t.isLiteral(declaration.init.body)
? t.blockStatement([t.returnStatement(declaration.init.body)])
: (declaration.init.body as t.BlockStatement)
);
newDeclaration.returnType = declaration.init.returnType;
p.replaceWith(newDeclaration);
Expand Down

0 comments on commit 4d8453b

Please sign in to comment.