Skip to content
  • Lauren Tan's avatar
    Don't use loose mode in @babel/plugin-transform-spread · ba572b8f
    Lauren Tan authored
    In
    [`loose`](https://babeljs.io/docs/babel-plugin-transform-spread#loose)
    mode, this plugin treats all iterables as arrays. This was causing
    issues when compiling Zod (inlined into babel-plugin-react-compiler),
    causing it to have a single element of `undefined: undefined` which
    violates the zod schema
    
    Note the spread below in Zod which was being transformed incorrectly:
    
    ```js
    const pairs = [...ctx.data.entries()].map(([key2, value], index) => {
      return {
        key: keyType._parse(new ParseInputLazyPath(ctx, key2, ctx.path, [index, "key"])),
        value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
      };
    });
    ```
    ba572b8f