Skip to content

Fastify 3.14.1 breaks fastify-websocket Typescript definitions #2967

@mattbishop

Description

@mattbishop

💥 Regression Report

With fastify 3.14.0 and fastify-websocket 3.1.0, one is able to write the following Typescript code to set up a web socket endpoint.

Last working version

Worked up to version: 3.14.0

Stopped working in version: 3.14.1

To Reproduce

Steps to reproduce the behavior:

  const server = fastify()
  server.register(require("fastify-websocket"))

  server.get("/ws", {
    websocket: true
  },
  createWSHandler())
}

When tsc is run, this error is presented:

error TS2345: Argument of type '{ websocket: boolean; }' is not assignable to parameter of type 'RouteShorthandOptions<Server, IncomingMessage, ServerResponse, RouteGenericInterface, unknown, FastifySchema>'.
  Object literal may only specify known properties, and 'websocket' does not exist in type 'RouteShorthandOptions<Server, IncomingMessage, ServerResponse, RouteGenericInterface, unknown, FastifySchema>'.

Expected behavior

tsc should omit no errors.

Your Environment

  • node version: 12.21.0
  • fastify version: >=3.14.1
  • os: Mac 11.2.3
  • Typescript 4.2.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions