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

Stricter return type for makeValidator #114

Merged
merged 1 commit into from
Dec 30, 2019
Merged

Stricter return type for makeValidator #114

merged 1 commit into from
Dec 30, 2019

Conversation

lostfictions
Copy link
Contributor

This PR makes the return type for makeValidator stricter, helping to ensure that you're returning a value from the validator that at least looks right.

The caveat here is that JSON.parse returns any, so if that's your first step you'll have to use something like a user-defined typeguard (see isArrayOfStrings helper added to test file) to further refine the type if you want TS to catch anything. But this should still help if, say, you write makeValidator<number>(....) and try to return new Date(....) at the end of it.

@af af merged commit a55cec8 into af:master Dec 30, 2019
@af
Copy link
Owner

af commented Dec 30, 2019

👍 thanks!

tuannm151 pushed a commit to BSSCommerce/shopify-envalid that referenced this pull request Jul 1, 2024
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.

3 participants