Skip to content

Conversation

@mrazauskas
Copy link
Contributor

@mrazauskas mrazauskas commented Aug 15, 2025

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.ts and packages/validator/transpile.test-d.ts. These two need more attention (I mean, more careful review).

Todo List:

  • All commits are cryptographically signed
  • Feature/Fix fully implemented
  • Updated relevant types
  • Added tests (if applicable)
    • Unit tests
    • Fuzz tests
    • Type tests
    • Benchmark tests
  • Updated relevant documentation
  • Updated relevant examples

@mrazauskas mrazauskas requested a review from a team as a code owner August 15, 2025 05:02
const typeErrorMiddleware = {
before: (request: MutableContextRequest) => {
// @ts-expect-error
// @ts-expect-error!
Copy link
Contributor Author

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..

Comment on lines +17 to +18
expect<SanitizeKeyPrefixLeadingNumber<"1234">>().type.toBe<"_1234">();
expect<SanitizeKeyPrefixLeadingNumber<"01234">>().type.toBe<"_01234">();
Copy link
Contributor Author

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.

@willfarrell
Copy link
Member

Thanks for the PR! Is this ready for review?

@mrazauskas
Copy link
Contributor Author

Yes. I went through again, nothing more to add. Ready for review!

@willfarrell willfarrell merged commit f4090b0 into middyjs:main Aug 22, 2025
13 checks passed
@willfarrell
Copy link
Member

Huge thanks for all the work on this.

@mrazauskas mrazauskas deleted the use-tstyche branch August 22, 2025 12:17
@mrazauskas
Copy link
Contributor Author

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.

@Puppo
Copy link
Contributor

Puppo commented Aug 22, 2025

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 🌟

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Move from tsd to tstyche

4 participants