Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
omarpanait opened this issue Jan 7, 2025 · 0 comments
Open

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

omarpanait opened this issue Jan 7, 2025 · 0 comments

Comments

@omarpanait
Copy link

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 for installing Fastify with Typescript but I keep getting the type error.

{
  "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"
  }
}
{
    "extends": "@tsconfig/node18/tsconfig.json",
    "compilerOptions": {
        "outDir": "./dist",
        "lib": ["es2018"],
        "target": "es2018"
    }

}
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<Server<typeof IncomingMessage, typeof ServerResponse>, 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant