MobiDev / rbxts-transformer-fusion

5 stars 1 forks source link

Error when there is children under component #3

Open Rudy-Dev opened 2 years ago

Rudy-Dev commented 2 years ago

I'm using 0.3.1 version of the transformer.

main.tsx

import Fusion from "@rbxts/fusion";
import Div from "./components/div";

const Main = (): Instance => {
    return (
        <screengui>
            <Div>
                <textbox />
            </Div>
        </screengui>
    );
};
export default Main;

div.tsx

import Fusion from "@rbxts/fusion";
import Corner from "./corner";

export default function Div(): Instance {
    return (
        <frame>
        </frame>
    );
}

The error.

src/client/UI/Main.tsx:4:63 - error TS2554: Expected 0 arguments, but got 1.

4     return (Fusion.New("ScreenGui")({ [Fusion.Children]: [Div({ [Fusion.Children]: [Fusion.New("TextBox")({})] })] }));
Rudy-Dev commented 2 years ago

Found an ugly way to go around the error.

function Div(props: { text: string } | { ____FusionChildren: Frame[] }): Instance {
    return (
        <frame>
        </frame>
    );
}