fastify / fastify/help

Property 'get' does not exist on type 'FastifyInstance'

Open
#1,077 0 comments 0 reactions 0 assignees View on GitHub
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.

![Screenshot from 2025-01-07 04-29-56](https://github.com/user-attachments/assets/1f40bae4-bce6-4567-9376-5b7cf95bb61c)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.