Skip to content

chore: migrate type tests to TSTyche assertions (part two)#6727

Merged
mcollina merged 7 commits into
fastify:mainfrom
mrazauskas:use-tstyche-assertions-part-two
Jun 7, 2026
Merged

chore: migrate type tests to TSTyche assertions (part two)#6727
mcollina merged 7 commits into
fastify:mainfrom
mrazauskas:use-tstyche-assertions-part-two

Conversation

@mrazauskas

Copy link
Copy Markdown
Contributor

Following up on #6532
Split from #6525

This PR follows up on #6532 and migrates assertions in the following types of tests to TSTyche:

register.test-d.ts
reply.test-d.ts
request.test-d.ts
route.test-d.ts
schema.test-d.ts
serverFactory.test-d.ts
type-provider.test-d.ts
using.test-d.ts

For the first part of migration see #6726. Hopefully, a smaller PR makes it easier to review the changes.

Changes

A few notes on the changes made:

  • In tsd assertions, the expected value comes first (differently from JavaScript assertions), so I had to swap expected and actual like here:
    - expectType<FastifyBaseLogger>(fastify().log)
    + expect(fastify().log).type.toBe<FastifyBaseLogger>()
  • When possible, I used a stricter .toBe() instead of .toBeAssignableTo() (assignability can be assumed)
  • Where possible, I replaced @ts-expect-error with .not.toBeCallableWith() and .not.toHaveProperty() (improves readability)
  • I have sorted imports manually for consistency

Checklist

Signed-off-by: mrazauskas <tom@mrazauskas.de>
Comment thread test/types/route.test-d.ts
Comment thread test/types/route.test-d.ts
Comment thread test/types/type-provider.test-d.ts
Comment thread test/types/using.test-d.ts
Signed-off-by: mrazauskas <tom@mrazauskas.de>
@Tony133 Tony133 requested a review from a team May 18, 2026 12:49

@Tony133 Tony133 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mrazauskas

Copy link
Copy Markdown
Contributor Author

The first part (#6726) got merged. So this PR can also remove tsd. See last commit (f753130).

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina enabled auto-merge (squash) June 7, 2026 14:28
@mcollina mcollina merged commit a4e9fd2 into fastify:main Jun 7, 2026
33 checks passed
@mrazauskas mrazauskas deleted the use-tstyche-assertions-part-two branch June 7, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

typescript TypeScript related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants