teslamotors / informed

A lightweight framework and utility for building powerful forms in React applications
https://teslamotors.github.io/informed
MIT License
956 stars 174 forks source link

Types for FormState indicate unknown for values #383

Closed denno020 closed 2 years ago

denno020 commented 2 years ago

Describe the bug The FormState type in index.d.ts is currently using Record types with <string, unknown>. I don't believe the value is unknown, it's always going to be a string, as we're dealing with form inputs right? Informed has always assumed that the value passed into an input is a string, even if they're numbers, they're always treated as a string.. At least that has been my experience.

To Reproduce This is a super simple Sandbox that simply shows the error that Typescript will display because the type information for the (in this case) values object is defined as <string, unknown>. We can also see the Typescript errors becuase Form and Input don't have type declarations, which is very annoying, but there is another issue related to that.

https://codesandbox.io/s/informed-js-types-bug-1lxwt

denno020 commented 2 years ago

Sorry accidentally clicked the close button 😞

joepuzzo commented 2 years ago

This is far from true. Informed has the ability to have inputs that store anything from dates to complex objects. It was unknown by design. In addition you can have highly nested value states and arrays. See the docs for examples.