TS2314: Generic type 'FastifyInstance ' requires 5 type argument(s).
gustawdaniel opened this issue · 4 comments
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.
You are using the wrong version.
7.x
is used for fastify@4.x
.
5.x
is used for fastify@3.x
I am reopen this issue because we forgot to update the supported fastify version.
Lines 193 to 196 in b863495
I am confirming, update to fastify@4.x fixed problem.
Would you like to send a Pull Request to bump the minimum Fastify version?