You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{types}from'mobx-state-tree';exportconstErrorStore=types.model('ErrorStore',{value: '',}).actions((self)=>({set(value: string){self.value=value;},reset(){self.value='';},})).views((self)=>({getformattedValue(){returnself.value;},}));exportconstNoDisplayError=ErrorStore.named('NoDisplayError').views(()=>({getformattedValue(){returnundefined;},}));constInputStore=types.model("InputStore",{value: "",// developer should explicitly specify whether validation errors should be displayed or noterror: types.union(ErrorStore,NoDisplayError)});constPasswordInputStore=InputStore.named("PasswordInputStore").props({// we have strict requirements for password, so validation errors should be displayed by defaulterror: types.optional(types.union(ErrorStore,NoDisplayError),()=>ErrorStore.create({}))});constpasswordS=PasswordInputStore.create({});
Describe the expected behavior
Initialization of PasswordInputStore should not require specifying optional error property.
Describe the observed behavior
TypeScript fails as error property is not provided.
TS2345: Argument of type '{}' is not assignable to parameter of type 'ModelCreationType<{ value: string | undefined; error: EmptyObject & Partial<{ value: string | undefined; }>; }>'.
Property 'error' is missing in type '{}' but required in type '{ error: EmptyObject & Partial<{ value: string | undefined; }>; }'.
The text was updated successfully, but these errors were encountered:
Minimal reproduction code
Describe the expected behavior
Initialization of
PasswordInputStore
should not require specifying optionalerror
property.Describe the observed behavior
TypeScript fails as
error
property is not provided.The text was updated successfully, but these errors were encountered: