parjs
parjs copied to clipboard
test: add type level tests
Since there is now a new feature for creating parsers with a constant string type (https://github.com/GregRos/parjs/pull/78), this feature should also have tests specifying that the correct type is returned.
There are likely many other cases where type level testing would be beneficial.
One possibility that could be used for this is https://github.com/arktypeio/arktype/tree/beta/ark/attest, which seems to not require much in terms of extra setup to get the tests running.
I previously implemented constant type inference for implicit parjsers. I haven't merged that in because I'm not sure the added type level complexity is actually useful for users (you can use string("abc") to get a constant type parjser instead).
This was a complex type level feature, and I added type level tests using https://github.com/jest-community/jest-runner-tsd/, which was ok but the developer experience wasn't that great.
Not sure if I want to go all the way to type level testing yet. Currently the cases should be somewhat nicely covered by using explicit type annotations.