Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types: replace declaration merging with mixin types #427

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

flakey5
Copy link

@flakey5 flakey5 commented Jan 19, 2024

For Fastify v5, background: fastify/fastify#5061

Opened this as it is now to get early feedback & insight. Used a class rather than an interface or type since the type needs to exist at runtime if we go with the currently proposed changes to the fastify-plugin api (see fastify/fastify#5061 (comment))

TODO:

  • Update/check tests.

cc @mcollina

Checklist

Copy link
Member

@climba03003 climba03003 left a comment

Choose a reason for hiding this comment

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

I believe if we going to be this approach, we should provides two types file.

  1. The plugin types with mixin.
  2. The declaration merging types named fastify-global.d.ts.

It allows the users to choice which approach fit there application.

The second option can be consumed using the tsconfig.json by the following way.

{
  "compilerOptions": {
    "types": ["@fastify/static/fastify-global"]
  }
}

@voxpelli
Copy link

voxpelli commented Sep 2, 2024

The second option can be consumed using the tsconfig.json by the following way.

{
  "compilerOptions": {
    "types": ["@fastify/static/fastify-global"]
  }
}

This only works for top level projects. I would much prefer it to be handled through an import {} from '@fastify/static/fastify-global', especially as specifying compilerOptions.types disables automatic loading of all @types/ types

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.

3 participants