Conversation
The typings for the FromSchema was too permissive and did not limit the keys to the form interface provided. Fixes elastic#60602
|
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
|
@patrykkopycinski Could you have a look at those 2 files. There are typings issue now that the
|
|
@elasticmachine merge upstream |
jloleysens
left a comment
There was a problem hiding this comment.
Tested ingest processors pipeline locally, and did not spot any regressions!
Great work @sebelga ! I left non-blocking comments in the code.
| readonly isSubmitted: boolean; | ||
| /** Flag that indicates if the form is being submitted. */ | ||
| readonly isSubmitting: boolean; | ||
| /** Flag that indicates if the form is valid. It can have three values: `true | false | undefined`. */ |
There was a problem hiding this comment.
nit; I would phrase this as:
/** Flag that indicates if the form is valid. If `undefined` then form validation has not been checked yet. */I think the TS boolean value is self-explanatory for the other states.
| /** The form id. If none was provided, "default" will be returned. */ | ||
| readonly id: string; | ||
| /** | ||
| * This handlers submits the form and returns its data and validity. If the form is not valid, the data will be `null` |
There was a problem hiding this comment.
typo: handlers -> handler
| import { to, from, EDITOR_PX_HEIGHT } from '../shared'; | ||
|
|
||
| const ignoreFailureConfig: FieldConfig = { | ||
| const ignoreFailureConfig: FieldConfig<any, any> = { |
There was a problem hiding this comment.
I know we discussed some of this offline, but seeing it now I am wondering if FieldConfig could be typed as:
interface FieldConfig<ValueType = unknown, T extends FormData = any> {}Then when it is used on individual fields we can write:
const ignoreFailureConfig: FieldConfig<boolean> = {
...
}I'm not certain how often we will set a type for FieldData when using this type directly, I can see it provides types for the validator, but perhaps the helpers/validators we provide cover a large number of cases already?
There was a problem hiding this comment.
Yes it makes total sense, I will update it 👍
|
Thanks for the review @jloleysens ! I made your suggested change to |
|
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]async chunks size
page load bundle size
History
To update your PR or re-run it, just comment with: |
This PR adds several enhancements to the form lib that I have made while working on the docs. Mainly refactors, TS types, comments.
It is now possible to declare the internal state interface (
I) when building the form.When providing a schema to a typed form, it validates that fields name are valid. None of the fields are required though.
<UseMultiFields />componentgetFieldDefaultValue())Fixes #60602