Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding types with optional properties made required #109

Open
sstarrAtmeta opened this issue May 15, 2018 · 4 comments
Open

Adding types with optional properties made required #109

sstarrAtmeta opened this issue May 15, 2018 · 4 comments

Comments

@sstarrAtmeta
Copy link

Properties payload, error, and meta 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 standard FluxStandardAction could remain in place while those additional versions could be used as needed.

@JaKXz
Copy link
Contributor

JaKXz commented Jul 26, 2018

@sstarrAtmeta are you still experiencing this pain? Would you like to take a stab at a PR? :)

@fredrikhr
Copy link
Contributor

fredrikhr commented Nov 7, 2018

We now have two variants solving this issue: #112 and #114.

@fredrikhr
Copy link
Contributor

@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.

@unional
Copy link
Contributor

unional commented Mar 20, 2022

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'>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants