qiniu / formstate-x

Manage state of form with ease.
https://qiniu.github.io/formstate-x
MIT License
33 stars 10 forks source link

Optimize `ValueOf` #67

Closed nighca closed 2 years ago

nighca commented 2 years ago

So that ValueOf supports any state (other than FieldState & FormState) which correctly implemented Validatable.

For code:

const fooState: Validatable<string> = ...

const formState = new FormState({
  foo: fooState
})

typeof fooState.value.foo // expected to be `string`

Without this PR, typeof fooState.value.foo will be derived as never.

With this PR, it will be derived as string as expected