Property 'get' does not exist on type 'FastifyInstance'
- Dominant language
- No language data
- Stars
- 68
- Forks
- 8
- Avg merge
- 11h 2m
- Merged PRs (30d)
- 2
Description
#### You have already researched for similar issues?
I searched for the problem and tried most solutions given without success.
#### What are you trying to achieve, or the steps to reproduce?
I followed the [documentation](https://fastify.dev/docs/latest/Reference/TypeScript/) for installing Fastify with Typescript but I keep getting the type error.
```json
{
"name": "fst",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "tsc -p tsconfig.json",
"start": "node ./dist/server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"fastify": "^5.2.1"
},
"devDependencies": {
"@tsconfig/node18": "^18.2.4",
"@types/node": "^22.10.5",
"typescript": "^5.7.2"
}
}
```
```json
{
"extends": "@tsconfig/node18/tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"lib": ["es2018"],
"target": "es2018"
}
}
```
```js
import fastify from 'fastify'
const server = fastify()
server.get('/ping', async (request, reply) => {
return 'pong\n'
})
server.listen({ port: 8080 }, (err, address) => {
if (err) {
console.error(err)
process.exit(1)
}
console.log(`Server listening at ${address}`)
})
server.listen({port: 3333})
```
#### What was the result you received?
Property 'get' does not exist on type 'FastifyInstance, IncomingMessage, ServerResponse, FastifyBaseLogger, FastifyTypeProviderDefault> & PromiseLike<...> & { ...; }'.ts(2339)
#### What did you expect?
To not show the error
#### Context
* *node version*: 18.19.1
* *fastify version*: 5.2.1
* *os*: Ubuntu 24.04.1
I also tried inside Docker with node:23.1-bullseye and I get the same error.

Contributor guide
Assessment
This issue has not been assessed yet.