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

Non-object record types are converted to objects #68

Open
OliverJAsh opened this issue Oct 21, 2019 · 0 comments
Open

Non-object record types are converted to objects #68

OliverJAsh opened this issue Oct 21, 2019 · 0 comments
Labels

Comments

@OliverJAsh
Copy link
Collaborator

OliverJAsh commented Oct 21, 2019

import { ofType, unionize, UnionOf } from 'unionize';

const MyUnion = unionize({
    MyVariant: ofType<string[]>(),
});
type MyUnion = UnionOf<typeof MyUnion>;

MyUnion.match({
    MyVariant: strs => strs.map(x => x), // runtime error!
});

Related: #67

Workaround: specify a value:

 const MyUnion = unionize({
     MyVariant: ofType<string[]>(),
-});
+}, { value: 'value' });
@OliverJAsh OliverJAsh added the bug label Oct 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant