Skip to content

types!: migrate static decorators to registration-scoped typing - #565

Open
mcollina wants to merge 2 commits into
mainfrom
feat/typed-static
Open

types!: migrate static decorators to registration-scoped typing#565
mcollina wants to merge 2 commits into
mainfrom
feat/typed-static

Conversation

@mcollina

Copy link
Copy Markdown
Member

Summary

Migrate @fastify/static typing from global FastifyReply declaration
augmentation to registration-scoped decorator inference.

Changes include:

  • types/index.d.ts now models reply decorators as plugin-applied effects;
  • types/index.test-d.ts rewritten to assert decorator availability only on
    registered instances;
  • README TypeScript notes updated to document the new registration-scoped
    behavior.

Dependency

This PR is part of the declaration-merging removal stack and depends on:

Please review/merge with that core change in mind.

Validation

  • npm run test:typescript
  • npm run lint -- types

Context

Refs fastify/fastify#5061.

@mcollina mcollina added the semver-major Issue or PR that should land as semver major label Mar 15, 2026
@Fdawgs

Fdawgs commented Mar 15, 2026

Copy link
Copy Markdown
Member

Do the inline type tags also need updating as part of this?

Comment thread types/index.d.ts
} from 'fastify'
import { Stats } from 'node:fs'

declare module 'fastify' {

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.

This would immediately break every application that relies on autoloading, as well as potentially many other patterns people are using in the wild. In large applications, the required refactoring could be significant.

I am not convinced we can ever fully remove declaration merging. It will likely need to remain supported indefinitely.

But there might be other options.

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

Labels

semver-major Issue or PR that should land as semver major

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants