I have the following types:
type formElement = {
name: string,
dirty: boolean,
valid: boolean,
Errors: Array<inputErrorType>,
Children: Array<inputElement> | Array<formElement>
}
type inputElement = {
name: string,
value: string,
dirty: boolean,
valid: boolean,
Errors: Array<inputErrorType>
};
Then i want to declare an object of those types.
var topForm: formElement = {
name: "MainForm",
type: "Form",
dirty: false,
valid: true,
Errors: [],
Children: [
{
name: "First",
value: "test",
dirty: true,
valid: true,
Errors: []
}
]
}
And I am getting an error that says that:
Could not decide which case to select union type
Obviously since i am missing the "Children" property, my item in the array should be an inputElement.
Children: Array<inputElement> | Array<formElement>
I needed to change to
Children: Array<inputElement | formElement>
Hence the array can have both inputElement or formElement not one of the either.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With