Skip to content

chore: migrate type tests to TSTyche assertions (part one)#6726

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

chore: migrate type tests to TSTyche assertions (part one)#6726
mcollina merged 5 commits into
fastify:mainfrom
mrazauskas:use-tstyche-assertions-part-one

Conversation

@mrazauskas

@mrazauskas mrazauskas commented May 18, 2026

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:

content-type-parser.test-d.ts
decorate-request-reply.test-d.ts
errors.test-d.ts
fastify.test-d.ts
hooks.test-d.ts
instance.test-d.ts
logger.test-d.ts
plugin.test-d.ts

For the second part of migration see #6727. 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() (improves readability)
  • I have sorted imports manually for consistency

Checklist

Signed-off-by: mrazauskas <tom@mrazauskas.de>
@github-actions github-actions Bot added the typescript TypeScript related label May 18, 2026
Comment thread test/types/fastify.test-d.ts
Comment thread test/types/hooks.test-d.ts
Comment thread test/types/hooks.test-d.ts
Comment thread test/types/instance.test-d.ts
Comment thread test/types/logger.test-d.ts
Comment thread test/types/instance.test-d.ts

@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:07
@mcollina mcollina merged commit 56ed8a7 into fastify:main Jun 7, 2026
32 checks passed
@mrazauskas mrazauskas deleted the use-tstyche-assertions-part-one branch June 7, 2026 14:16
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