Closed iamchathu closed 7 months ago
Hey @iamchathu ! I was unable to replicate the issue using the instructions you provided, are you able to provide a link to a GH repo or your full package.json+package-lock.json for closer inspection? :)
@jonnydgreen Please refer here. https://github.com/iamchathu/mercurius-ts-example
Only thing seems I have not mentioned is setting up the type to module in the packages.json
Only thing seems I have not mentioned is setting up the type to module in the packages.json
Ah yep, that triggered the issue!
I believe I've figured it out: the mercurius index.d.ts
is not nodenext compatible, so this will require a fix that would include a small refactor of the index.d.ts
file. For example, the following changes to index.d.ts
would resolve the issue:
type Mercurius = FastifyPluginCallback<mercurius.MercuriusOptions>
declare namespace mercurius {
// ...
export const mercurius: Mercurius
export { mercurius as default }
}
declare module "fastify" {
// ...
}
declare function mercurius(...params: Parameters<Mercurius>): ReturnType<Mercurius>
export = mercurius;
wdyt @mcollina ?
That would be perfect. Can you send a PR?
Yep, absolutely! I'll get that done this week :)
I created a new typescript respository with following Typescript config.
The following in the index.ts file as the example.
The dependencies versions looks like following
The error when transpiling the Typescript as the following,
I used following tool the test the esm support and the the exports.