You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: support BlockStatement arrow functions in codec parser
Previously, only implicit-return arrow functions were supported:
```typescript
const factory = () => t.string; // ✅ Worked
BlockStatement arrow functions with explicit returns would fail:
const factory = () => {
return t.string; // ❌ Error: "BlockStatement arrow functions are not yet supported"
};
```
This fix:
- Searches BlockStatement.stmts for ReturnStatement nodes
- Extracts the return value expression (returnStmt.argument)
- Passes it to parseCodecInitializer() for recursive parsing
- Validates that a return statement exists with a non-undefined argument
Both styles now produce identical schemas since they converge on the
same parseCodecInitializer() call with the return value expression.
Test case added using BooleanFromNullableWithFallback() with explicit
block syntax to verify the parser handles both arrow function styles.
0 commit comments