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

Update TypeScript types to match actual request object passed to handlers #64

Merged
merged 1 commit into from
Jul 3, 2020

Conversation

airhorns
Copy link
Member

@airhorns airhorns commented Jul 2, 2020

In the README it states (and in my experience also) the handler doesn't get a full on FastifyRequest object. It gets an http.IncomingMessage instead! This makes the TypeScript types reflect that.

Checklist

  • run npm run test and npm run benchmark
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message and code follows Code of conduct

…lers

In the README it states (and in my experience also) the handler doesn't get a full on `FastifyRequest` object. It gets an `http.IncomingMessage` instead! This makes the TypeScript types reflect that.
@airhorns
Copy link
Member Author

airhorns commented Jul 3, 2020

Fixes #60

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@SerayaEryn SerayaEryn left a comment

Choose a reason for hiding this comment

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

LGTM

@mcollina mcollina merged commit 0838d43 into fastify:master Jul 3, 2020
airhorns added a commit to airhorns/fastify-websocket that referenced this pull request Jul 16, 2020
This corrects an issue introduced in fastify#64 where upon adding `fastify-websocket` to a project all route handlers were (accidentally) assumed to be websocket handlers getting the different (and decidedly less useful) types. My bad! This corrects the issue by using a type-land overload of the RouteShorthand function definition to change the type of the handler only if the handler is in fact `{ websocket: true }`.

Also adds tests, `tsd` is handy!
airhorns pushed a commit to airhorns/fastify-websocket that referenced this pull request Jul 16, 2020
This corrects an issue introduced in fastify#64 where upon adding `fastify-websocket` to a project all route handlers were (accidentally) assumed to be websocket handlers getting the different (and decidedly less useful) types. My bad! This corrects the issue by using a type-land overload of the RouteShorthand function definition to change the type of the handler only if the handler is in fact `{ websocket: true }`.

Also adds tests, `tsd` is handy!
airhorns pushed a commit to airhorns/fastify-websocket that referenced this pull request Jul 16, 2020
This corrects an issue introduced in fastify#64 where upon adding `fastify-websocket` to a project all route handlers were (accidentally) assumed to be websocket handlers getting the different (and decidedly less useful) types. My bad! This corrects the issue by using a type-land overload of the RouteShorthand function definition to change the type of the handler only if the handler is in fact `{ websocket: true }`.

Also adds tests, `tsd` is handy!
mcollina added a commit that referenced this pull request Jul 17, 2020
…#68)

This corrects an issue introduced in #64 where upon adding `fastify-websocket` to a project all route handlers were (accidentally) assumed to be websocket handlers getting the different (and decidedly less useful) types. My bad! This corrects the issue by using a type-land overload of the RouteShorthand function definition to change the type of the handler only if the handler is in fact `{ websocket: true }`.

Also adds tests, `tsd` is handy!

Co-authored-by: Matteo Collina <hello@matteocollina.com>
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