fastify/fastify-websocket

Missing declaration file for module 'ws'

frndvrgs opened this issue ยท 1 comments

๐Ÿ› Bug Report

Compiling my fastify server using Typescript, I am getting an error message pointing out the missing the 'ws' module declaration file. When manually installing the corresponding DefinitelyTyped (@types/ws), the error disappears.

To Reproduce

  1. npm install
  2. npx tsc -w
[05:36:04] Starting compilation in watch mode...

node_modules/fastify-websocket/index.d.ts:5:28 - error TS7016: Could not find a declaration file for module 'ws'.
'D:/_software/electronic-publishing/social/node_modules/ws/index.js' implicitly has an 'any' type.
Try `npm install @types/ws` if it exists or add a new declaration (.d.ts) file containing `declare module 'ws';

5 import * as WebSocket from 'ws';

[05:36:07] Found 1 error. Watching for file changes.

Expected behavior

I believe that this dependency should be determined in fastify-websocket and not directly in my project.

Your Environment

  • node version: 14.10.1

  • fastify version: >=3.8.0

  • os: Windows

  • project dependencies:

    "dependencies": {
    "dotenv": "^8.2.0",
    "fastify": "^3.8.0",
    "fastify-compress": "^3.4.0",
    "fastify-cors": "^4.1.0",
    "fastify-helmet": "^5.0.3",
    "mercurius": "^6.2.0",
    "pg": "^8.4.2",
    "pg-format": "^1.0.4",
    "uuid": "^8.3.1"
    },
    "devDependencies": {
    "@types/node": "^14.14.7",
    "@types/pg": "^7.14.6",
    "@types/pg-format": "^1.0.1",
    "@types/uuid": "^8.3.0",
    "typescript": "^4.0.5"
    }

Thanks for reporting but that's expected, add manually.