Skip to content

Problems using it with TypeScript #2

Description

@kristianmandrup
fastify.ready(err => {
  if (err) throw err

  fastify.ws
    .on('connection', socket => {
      socket.on('message', msg => socket.send(msg)) // Creates an echo server
    })
})

Errors

[ts] Argument of type '(err: any) => void' is not assignable to parameter of type '() => void'.
(parameter) err: any

[ts] Property 'ws' does not exist on type 'FastifyInstance<{}, {}, {}>'.

Had to tweak it to the following to make it compile

fastify.ready(() => {
  fastify['ws']
    .on('connection', socket => {
      socket.on('message', msg => socket.send(msg)) // Creates an echo server
    })
})

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions