Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic nodes Typescript error #246

Closed
hthomas92 opened this issue Jan 19, 2023 · 2 comments
Closed

Dynamic nodes Typescript error #246

hthomas92 opened this issue Jan 19, 2023 · 2 comments
Labels
bug Something isn't working v2 Related to Baklava v2

Comments

@hthomas92
Copy link

Hello,
when trying to create a Dynamic node based on the example here, I get a Typescript error. The example works though, I was just wondering about how to get rid of the error.

Type '({ operation }: { operation: string; }) => { inputs: { input1: () => NumberInterface; input2?: undefined; }; } | { inputs: { input1: () => NumberInterface; input2: () => NumberInterface; }; }' is not assignable to type '(inputs: { operation: string; }, outputs: { result: number; }) => DynamicNodeUpdateResult'.
  Type '{ inputs: { input1: () => NumberInterface; input2?: undefined; }; } | { inputs: { input1: () => NumberInterface; input2: () => NumberInterface; }; }' is not assignable to type 'DynamicNodeUpdateResult'.
    Type '{ inputs: { input1: () => NumberInterface; input2?: undefined; }; }' is not assignable to type 'DynamicNodeUpdateResult'.
      Types of property 'inputs' are incompatible.
        Type '{ input1: () => NumberInterface; input2?: undefined; }' is not assignable to type 'DynamicNodeDefinition'.
          Property 'input2' is incompatible with index signature.
            Type 'undefined' is not assignable to type '() => NodeInterface<any>'.ts(2322)
@newcat
Copy link
Owner

newcat commented Jan 21, 2023

Thanks for the issue, this will be fixed in the next release. For now, you can add as DynamicNodeDefinition to the return value of the onUpdate function, like this:

onUpdate({ operation }) {
    if (operation === "Sine") {
        return {
            inputs: {
                input1: () => new NumberInterface("Input", 0),
            } as DynamicNodeDefinition,
        };
    } else {
        return {
            inputs: {
                input1: () => new NumberInterface("Input", 0),
                input2: () => new NumberInterface("Input", 0),
            } as DynamicNodeDefinition,
        };
    }
},

@newcat newcat added bug Something isn't working v2 Related to Baklava v2 labels Jan 21, 2023
newcat added a commit that referenced this issue Jan 21, 2023
@newcat
Copy link
Owner

newcat commented Jun 1, 2023

Fixed in v2.0.2-beta.4

@newcat newcat closed this as completed Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v2 Related to Baklava v2
Projects
None yet
Development

No branches or pull requests

2 participants