Git Product home page Git Product logo

Comments (5)

jaredLunde avatar jaredLunde commented on June 16, 2024 2

Am I missing something? Wouldn't this work nearly as well while remaining readable? I get that it doesn't display to the developer perfectly, but it is a slight improvement that type checks correctly which is the important thing.

export type FormFieldValues<Fields extends FormFields> = {
  [Key in keyof Fields]: Fields[Key] extends FieldAtom<infer Value>
    ? Value
    : Fields[Key] extends FormFields
    ? FormFieldValues<Fields[Key]>
    : Fields[Key] extends Array<infer Item>
    ? Item extends FieldAtom<infer Value>
      ? Value[]
      : Item extends FormFields
      ? FormFieldValues<Item>[]
      : never
    : never;
};

Screen Shot 2023-02-01 at 5 13 42 PM

Screen Shot 2023-02-01 at 5 13 27 PM

from form-atoms.

MiroslavPetrik avatar MiroslavPetrik commented on June 16, 2024 1

@jaredLunde Yes, the version from case 1 will be ok, as it is an improvement.

I don't like the readability of the _FormAtomValues from case 2 neither, it was only illustration that its possible to achieve :)

Maybe typescript will improve this automatically in the future, by eagerly resolving the 'generit type calls' instead of displaying them. Who knows.

from form-atoms.

jaredLunde avatar jaredLunde commented on June 16, 2024

I prefer the current type as it is more readable and thus easier to maintain.

from form-atoms.

github-actions avatar github-actions commented on June 16, 2024

🎉 This issue has been resolved in version 2.0.0-next.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

from form-atoms.

github-actions avatar github-actions commented on June 16, 2024

🎉 This issue has been resolved in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

from form-atoms.

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.