-
-
Notifications
You must be signed in to change notification settings - Fork 312
chore: upgrade TSTyche #4745
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
chore: upgrade TSTyche #4745
Conversation
|
"checkSourceFiles": true, | ||
"rejectAnyType": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These now are enabled by default.
This is awesome, thanks for working on this @mrazauskas |
Array.sort([1], Order.string) | ||
// @ts-expect-error: wrong `Order` type | ||
Array.sort(Order.string)([1]) | ||
when(pipe).isCalledWith([1], expect(Array.sort).type.not.toBeCallableWith(Order.string)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I add the when()
utility. As you see in this line, it is a helper that wraps an expression and allows calling it during the type test run. This allows passing expect()
as an argument and test a callback as if it is an argument of the outer function.
Similar to .toBeCallableWith()
, the implementation erases when()
. The line above becomes:
; (pipe) ([1], (Array.sort) (Order.string))
@gcanti Could you take a look, please. There are only 31 instances of If |
agreed
no problem, I'm fine with a beta, there's no rush, we are happy to help you out with the next release of |
Wonderful! Thanks so much. |
Type
Description
This PR upgrades TSTyche to version 4. (It is still in beta, because I plan to implement few more features and that will break programatic usage. Nothing breaking is planned for CLI usage.)
The highlight of TSTyche 4 are the ability matchers:
.toBeCallableWith()
,.toBeConstructableWith()
, etc. Detailed release notes can be found here: https://tstyche.org/releases/tstyche-4In this PR many
// @ts-expect-error
are replaced with.not.toBeCallableWith()
. There are much more// @ts-expect-error
still left around. I will handle them later. The idea was to show you what is possible and to ask for feedback. Also these tests were a great playground to try out new features.How it Works?
Implementation of the ability matchers is somewhat similar to
ts-blank-space
. After retrieving diagnostics for a file, TSTyche creates a virtual copy of it with erased assertions and asks TypeScript for diagnostics again.An assertion like this:
Becomes:
Any found error are reported (or silenced if
.not
is included):