Using the Fastify plugin in an ESM Fastify app results in a Typescript build error.
src/plugins/graphql/index.ts:147:28 - error TS2769: No overload matches this call.
Overload 1 of 3, '(plugin: FastifyPluginCallback<{ path: string; baseURL: string; endpointURL: string; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
Argument of type 'typeof import("/.../node_modules/.pnpm/altair-fastify-plugin@7.2.4_fastify@4.28.1/node_modules/altair-fastify-plugin/dist/index")' is not assignable to parameter of type 'FastifyPluginCallback<{ path: string; baseURL: string; endpointURL: string; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
Expected Behavior
The plugin should be able to be used with ESM enabled.
Steps To Reproduce
Set "type": "module" in your package.json and add typescript support.
import AltairFastify from 'altair-fastify-plugin';
import Fastify from 'fastify';
const app = Fastify();
app.register(AltairFastify);
Fastify has fixed their plugins using the "infamous triplet" with module.exports (https://github.com/fastify/fastify/issues/4349). Ideally it can be applied to this plugin so it supports both CJS/ESM seamlessly.
Is there an existing issue for this?
Current Behavior
Using the Fastify plugin in an ESM Fastify app results in a Typescript build error.
Expected Behavior
The plugin should be able to be used with ESM enabled.
Steps To Reproduce
Set "type": "module" in your package.json and add typescript support.
Environment
Additional context
Fastify has fixed their plugins using the "infamous triplet" with module.exports (https://github.com/fastify/fastify/issues/4349). Ideally it can be applied to this plugin so it supports both CJS/ESM seamlessly.