Eomm / fastify-raw-body

Request raw body
MIT License
45 stars 10 forks source link

Error when registering the latest version - No overload matches this call. #43

Closed BE-CH closed 1 year ago

BE-CH commented 1 year ago

I get the error below when trying to register the plugin.

image

instance.d.ts(115, 19): This type parameter might need an `extends T extends (...args: any[]) => any ? (this: FastifyRequest<RouteGenericInterface, RawServerDefault, http.IncomingMessage, ... 4 more ..., ResolveFastifyRequestType<...>>, ...args: Parameters<T>) => ReturnType<...> : T` constraint.

My code:

import fastifyRawBody from 'fastify-raw-body';

// Register FastifyRAW
await fastify.register(fastifyRawBody, {
  field: 'rawBody', // change the default request.rawBody property name
  global: false, // add the rawBody to every request. **Default true**
  encoding: 'utf8', // set it to false to set rawBody as a Buffer **Default utf8**
  runFirst: true, // get the body before any preParsing hook change/uncompress it. **Default false**
  routes: ['/order/webhook'], // array of routes, **`global`** will be ignored, wildcard routes not supported
});

My packages:

    "fastify": "^4.10.2",
    "fastify-raw-body": "^4.1.3",

Not sure why it happens - but it happened after I updated to the latest version. It also happened with some other plugins, but I just updated those and the error when away for the other plugins

Eomm commented 1 year ago

I think we should apply the same nodenext TS compatibility here https://github.com/search?q=org%3Afastify+nodenext&type=pullrequests

Could you try to install fastify v4.10.0? Which was your previous version in use?

BE-CH commented 1 year ago

I think we should apply the same nodenext TS compatibility here https://github.com/search?q=org%3Afastify+nodenext&type=pullrequests

Could you try to install fastify v4.10.0? Which was your previous version in use?

It does not seem to make any difference in Fastify v4.10.0.

I previously used these versions:

    "fastify": "^4.9.2",
    "fastify-raw-body": "^4.1.3",

but that seems to not even work🤔

FastifyError [Error]: fastify-plugin: fastify-raw-body - expected '^4.10.x' fastify version, '4.9.2' is installed

UPDATE: I got it working with the versions below:

    "fastify": "4.9.2",
    "fastify-raw-body": "4.1.2",

but it would be great with support for Fastify 4.10.2 and FastifyRawBody 4.1.3

Eomm commented 1 year ago

FastifyError [Error]: fastify-plugin: fastify-raw-body - expected '^4.10.x' fastify version, '4.9.2' is installed

Yes, this was necessary because now this plugin uses request.routeOptions that was released in fastify v4.10

I got it working with the versions below:

Thanks, it is helpful to replicate and solve the issue

Eomm commented 1 year ago

@BE-CH could you verify that the PR #45 works for you?

BE-CH commented 1 year ago

@BE-CH could you verify that the PR #45 works for you?

It works! Thank you so much :)

Eomm commented 1 year ago

I did not release it

I will close later today

BE-CH commented 1 year ago

@Eomm will you release it to a new version? or can I simply just do yarn install again to get the latest additions?

Eomm commented 1 year ago

4.2.0 released now!