-
-
Notifications
You must be signed in to change notification settings - Fork 83
Closed
Labels
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Fastify version
^3.29.0
Plugin version
^7.1.2
Node.js version
v16.13.2
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
fedora 37
Description
When I am installing this library by require there is no problem, but when I am using import than I see warnings in typescript
TS2314: Generic type 'FastifyInstance ' requires 5 type argument(s).
and my rest routes are treated as incompatible.
Steps to Reproduce
adding this code
'use strict'
const fastify = require('fastify')()
fastify.register(require('@fastify/websocket'))
fastify.register(async function (fastify) {
fastify.get('/', { websocket: true }, (connection /* SocketStream */, req /* FastifyRequest */) => {
connection.socket.on('message', message => {
// message.toString() === 'hi from client'
connection.socket.send('hi from server')
})
})
})
fastify.listen({ port: 3000 }, err => {
if (err) {
fastify.log.error(err)
process.exit(1)
}
})
and changing require to import with having pure http endpoints defined ealier
Expected Behavior
I expect to not see typescript errors or rather see warning about incompatibility during installation.