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

matches.tuple typed as Validator<unknown, never> #473

Closed
speigg opened this issue Sep 17, 2021 · 4 comments · Fixed by #474
Closed

matches.tuple typed as Validator<unknown, never> #473

speigg opened this issue Sep 17, 2021 · 4 comments · Fixed by #474

Comments

@speigg
Copy link

speigg commented Sep 17, 2021

I'm seeing this bug:

matches.tuple([matches.number, matches.number, matches.number]) 
// expected type: Validator<unknown, [number,number,number]>
// actual type: Validator<unknown, never>

I'm seeing Validator<unknown, never> for all matches.tuple types

@Blu-J
Copy link
Owner

Blu-J commented Sep 17, 2021

Yes, it should be exactly the output, I have a test for this, will go about creating a fix. Thanks for finding, I think I have a unit test that will stop the regression, will work on it.

      it("should be able to check tuple exact shape", () => {
        const input = [1, 2, 3];
        const matcher = matches.tuple([
          matches.number,
          matches.number,
          matches.number,
        ]);
        // @ts-expect-error
        const outputWrong: [number, number] = matcher.unsafeCast(input);
        const outputRight: [number, number, number] = matcher.unsafeCast(input);
        // expected type: Validator<unknown, [number,number,number]>
        // actual type: Validator<unknown, never>;
        expect(outputRight).toEqual(input);
        expect(outputWrong).toEqual(input);
      });

This will hit master, but there are new features so going to be a new version. What version would you also like for me to backprop this to?

@speigg
Copy link
Author

speigg commented Sep 19, 2021

A new version is fine! This is a great library, thanks for creating it!

@Blu-J
Copy link
Owner

Blu-J commented Sep 21, 2021

Had to change the api for the creation of the tuples because of the ability to infer and tuples

@speigg
Copy link
Author

speigg commented Sep 22, 2021

Seems like a nicer API this way anyway, thanks for the fix!

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 a pull request may close this issue.

2 participants