Skip to content

refactor(types): migrate from tsd to tstyche#95

Open
Puppo wants to merge 4 commits into
mcollina:mainfrom
Puppo:refactor/types-migrate-to-tstyche
Open

refactor(types): migrate from tsd to tstyche#95
Puppo wants to merge 4 commits into
mcollina:mainfrom
Puppo:refactor/types-migrate-to-tstyche

Conversation

@Puppo

@Puppo Puppo commented Jun 17, 2026

Copy link
Copy Markdown

Summary

Migrates type tests from tsd to tstyche. Also bumps GitHub Actions to v6 and extends the CI Node.js matrix to 24.x, and 26.x.

Puppo added 4 commits June 17, 2026 08:26
- Replace tsd dependency with tstyche
- Update test:typescript script
- Convert types/plugin.test-d.ts to types/plugin.tst.ts
- Update assertion syntax to use tstyche fluent API
- Convert plugin.d.ts from CommonJS-style 'export =' to ESM 'export default'
  to match the package's ESM module mode (required by tstyche/NodeNext)

Refs: nearform/fastify-slow-down#625
- actions/checkout: v4 → v6
- actions/setup-node: v3 → v6
- fastify/github-action-merge-dependabot: keep on the v3 major (no v6 has
  been released for this action)
- Node.js test matrix: add 24.x and 26.x alongside the existing 20.x and 22.x
Group the assertions into nested describe() blocks — one per public API
surface (plugin registration, FastifyInstance decorators, FastifyReply
decorator) — and wrap each scenario in a named test().

The reporter now shows 6 named tests across 4 groups:
  fastify-html
    plugin registration
      + registers via the default export
      + accepts the async option
    FastifyInstance decorator: html()
      + returns a string for any template literal input
    FastifyInstance decorator: addLayout()
      + accepts a render function and an optional skipOnHeader option
    FastifyReply decorator: html()
      + returns FastifyReply for any template literal input
      + can be used inside a route handler with default options

The two registration-only tests and the route-handler smoke test are
type-checked even though they have no expect() assertion — tstyche still
verifies the code in the test body compiles. 3 explicit type assertions
remain.
Each test previously repeated the same three lines:
  const server = fastify()
  server.register(fastifyHtml, ...)
  server.after(() => { ... })

Extract a callback-style helper that owns all of that, so each test
body becomes a single withServer((server) => { ... }) call. The
helper also defaults options to {} so registration smoke tests stay
one-liner.

Reporter output is unchanged: 6 named tests in 4 groups, 3 type
assertions.
@Puppo Puppo marked this pull request as ready for review June 17, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant