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

Multiple brands schema results to never #87

Closed
zkulbeda opened this issue Aug 11, 2023 · 2 comments · Fixed by #88
Closed

Multiple brands schema results to never #87

zkulbeda opened this issue Aug 11, 2023 · 2 comments · Fixed by #88
Assignees
Labels
bug Something isn't working

Comments

@zkulbeda
Copy link
Contributor

zkulbeda commented Aug 11, 2023

Hi! Current implementation of branded types uses single symbol for single branded type, that results to never type in tests

test('should allow multiple branding', () => {
const branded1 = brand(string(), '1');
const branded2 = brand(branded1, '2');
type Branded2 = Output<typeof branded2>;
expectTypeOf(branded1).not.toEqualTypeOf(branded2);
expectTypeOf<Branded2>().toEqualTypeOf<string & Brand<'1'> & Brand<'2'>>();
});

image

It happends because typescript resolves { [symbol]: "1"} & { [symbol]: "2" } to never.

I'll make a pr for fix, that replaces single value to object of values

@fabian-hiller fabian-hiller self-assigned this Aug 11, 2023
@fabian-hiller fabian-hiller added the bug Something isn't working label Aug 11, 2023
@fabian-hiller
Copy link
Owner

Thank you! Can you also add a test that checks this?

@zkulbeda
Copy link
Contributor Author

@fabian-hiller sure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants