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 asserts annotations #194

Merged
merged 7 commits into from
Dec 19, 2020
Merged

Conversation

mmkal
Copy link
Contributor

@mmkal mmkal commented Dec 9, 2020

Fixes #159

Also adds:

  • Type-level tests
  • A generic typearg for ArrayPredicate and ObjectPredicate. So ow.array.ofType(ow.string) infers string[] and ow.object.exactShape({ foo: ow.string, bar: ow.object.exactShape({ baz: ow.number }) }) infers { foo: string; bar: { baz: number } }
  • A Shape -> TypeOfShape helper

Changes:

  • The optional modifier now makes each predicate ThePredicate<T | undefined> rather than Predicate (which could lead to uncaught NREs)
  • The hidden create-constructor-function-thing is no longer allowed to receive undefined for any value, since undefineds should now be properly tracked.

Also adds:
- Type-level tests with expect-type
- A generic typearg for ArrayPredicate and ObjectPredicate
- A Shape -> TypeOfShape helper

Changes:
- The `optional` modifier now makes each predicate ThePredicate<T | undefined> rather than Predicate<T> (which could lead to uncaught NREs)
- The hidden create-constructor is no longer allowed to pass in undefined for any value, since undefineds should now be properly tracked.
@mmkal mmkal changed the title Add asserts annotations to main function Add asserts annotations Dec 10, 2020
@sindresorhus
Copy link
Owner

Thanks for working on this 🙌

@sindresorhus sindresorhus merged commit 66a4228 into sindresorhus:master Dec 19, 2020
@sindresorhus
Copy link
Owner

This looks great! Thank you :)

@mmkal mmkal deleted the asserts-types branch December 19, 2020 17:30
vladfrangu pushed a commit to vladfrangu/ow that referenced this pull request Jan 7, 2021
vladfrangu pushed a commit to vladfrangu/ow that referenced this pull request Jan 7, 2021
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.

Add support for the new asserts keyword in TS 3.7
2 participants