-
-
Notifications
You must be signed in to change notification settings - Fork 391
chore: use TSTyche for type testing #1432
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
Conversation
| const typeErrorMiddleware = { | ||
| before: (request: MutableContextRequest) => { | ||
| // @ts-expect-error | ||
| // @ts-expect-error! |
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.
TSTyche is able to check messages of error suppressed by // @ts-expect-error. This is useful because hides any kind of // @ts-expect-error. Since type tests are not executed, there is no way to find the problems.
A message after // @ts-expect-error is required. The ! in this lines tells to ignore that. But maybe I should include the message? Hm..
| expect<SanitizeKeyPrefixLeadingNumber<"1234">>().type.toBe<"_1234">(); | ||
| expect<SanitizeKeyPrefixLeadingNumber<"01234">>().type.toBe<"_01234">(); |
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.
expect() can compare two types. The utilities tested in this file are working with types, not values. So I refactored the tests to compare two types instead a type and inferred type of an expression.
Signed-off-by: mrazauskas <[email protected]>
|
Thanks for the PR! Is this ready for review? |
|
Yes. I went through again, nothing more to add. Ready for review! |
|
Huge thanks for all the work on this. |
|
Thank you too! Glad to see you find TSTyche useful. I will come back with some refinements. And huge thanks for @Puppo! For the initiative. |
Apologies, but I’m a bit busy in the last period! Thank you so much, @mrazauskas, for your fantastic work 🌟 |
What does this implement/fix? Explain your changes.
This PR migrates all type tests to TSTyche.
It is a large change. To keep to the diff readable, I did not introduce
test()helpers and kept file names as they are. These changes are left for follow up PRs. A config file is added, but it can be removed after renaming the files.Does this close any currently open issues?
Closes #1381
Closes #1383
Any other comments?
It appeared that a couple of files were not picked up by
tsd. Namely:packages/util/type-utils.test-d.tsandpackages/validator/transpile.test-d.ts. These two need more attention (I mean, more careful review).Todo List: