GithubHelp home page GithubHelp logo

Comments (7)

fabian-hiller avatar fabian-hiller commented on June 15, 2024 1

If you provide me your code via StackBlitz I can try to investigate it. Here is a template: https://stackblitz.com/edit/modular-forms-react?file=src/routes/login.tsx

from modular-forms.

FujishigeTemma avatar FujishigeTemma commented on June 15, 2024 1

Make sense. Thank you!

from modular-forms.

fabian-hiller avatar fabian-hiller commented on June 15, 2024

You wrote "items.0.data.max_number" instead of "items.0.data.max_select", does this cause the problem? Also, when using arrays, I recommend using our specialized array functions. In your case you should probably use replace. Read more here: https://modularforms.dev/qwik/guides/field-arrays#use-array-methods

from modular-forms.

FujishigeTemma avatar FujishigeTemma commented on June 15, 2024

You wrote "items.0.data.max_number" instead of "items.0.data.max_select", does this cause the problem?

Sorry, I just made a mistake when I simplified my code for reproduction (fixed). So it was not in my actual code.

Also, when using arrays, I recommend using our specialized array functions. In your case you should probably use replace.

Thank you for your advice! But unfortunately I got almost same error. For me, it seems that, with a object { x: string, y: number } | { x: string, z: boolean }, inferred type of x is correct but types of y, z become never.

image
image

from modular-forms.

FujishigeTemma avatar FujishigeTemma commented on June 15, 2024

Sure! Here is a reproduction from template: https://stackblitz.com/edit/modular-forms-react-7twxqr?file=src%2Froutes%2Freproduction.tsx

from modular-forms.

fabian-hiller avatar fabian-hiller commented on June 15, 2024

Thank you! I plan to have a look on it on the weekend.

from modular-forms.

fabian-hiller avatar fabian-hiller commented on June 15, 2024

It seems that this is the normal behavior of TypeScript when working with unions. The y doesn't exist in every case, which is why TypeScript displays an error. A workaround might be to use setValues: https://modularforms.dev/react/api/setValues

setValues(u, { x: 'ok', y: 'also ok' });
setValues(v, { data: { x: 'ok', y: 'also ok' } });

from modular-forms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.