Skip to content

Add asserts annotations#194

Merged
sindresorhus merged 7 commits intosindresorhus:masterfrom
mmkal:asserts-types
Dec 19, 2020
Merged

Add asserts annotations#194
sindresorhus merged 7 commits intosindresorhus:masterfrom
mmkal:asserts-types

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