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

Add output indexed types to option and either #171

Merged
merged 3 commits into from
Oct 10, 2022

Conversation

mlegenhausen
Copy link
Contributor

This PR adds indexed output types to the option and either codecs. This solves the problem that it is currently not possible to do Json.pipe(option(t.unknown)) or Json.pipe(either(t.string, t.unknown)) as the fp-ts types can not be assigned to JsonRecord. As we don't want to loose the interface representation in fp-ts it is the best to add an indexed version to io-ts-types.

This is related to gcanti/fp-ts#1734

/**
* @since 0.5.18
*/
export type NoneOutput = t.OutputOf<typeof None>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a particular reason for using t.OutputOf here?

I was expecting export type NoneOutput = { _tag: 'None' }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preventing double definition and possible divergence.

@gcanti
Copy link
Owner

gcanti commented Oct 5, 2022

it is currently not possible to do Json.pipe(option(t.unknown))

We should add some tests

@gcanti gcanti merged commit 3d99e52 into gcanti:master Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants