Open sstarrAtmeta opened 6 years ago
@sstarrAtmeta are you still experiencing this pain? Would you like to take a stab at a PR? :)
We now have two variants solving this issue: #112 and #114.
@sstarrAtmeta with #114 now merged, you can now define the type by using FSAWithPayload
to require a payload
property. Or simply use FSAAuto
which will infer whether payload
should be required depending on whether you specify a type other than undefined
.
I think this can be closed.
btw if you want to look for a more generic solution to this problem, there is a RequiredPick
type from type-plus
so that you can do:
type YourAction = RequiredPick<FSA<'ACTION', string>, 'payload'>
Properties
payload
,error
, andmeta
are all optional properties according to documentation. However I believe there are cases where actions may need to make these properties required ( such as actions based around a text search ). Adding interfaces such as those suggested by @dsanders1234 in a previous issue about these options not being correctly typed as optional strikes me as a good approach, and I'm thinking of doing something similar as a workaround. The standardFluxStandardAction
could remain in place while those additional versions could be used as needed.