Graphql-yoga: Could not find a declaration file for module 'ws'

Created on 14 Jun 2018  ยท  7Comments  ยท  Source: dotansimha/graphql-yoga

I have a vanilla project setup:

{
  "name": "test",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "graphql-yoga": "^1.14.8"
  },
  "devDependencies": {
    "@types/node": "10.1.2",
    "typescript": "^2.9.2"
  }
}

{
  "compilerOptions": {
    "strict": true,
    "noImplicitReturns": true,
    "esModuleInterop": true,
    "module": "commonjs",
    "target": "es2015",
    "sourceMap": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "lib": [
      "es2015",
      "esnext.asynciterable"
    ]
  },
  "include": ["./*.ts"]
}
import { GraphQLServer } from "graphql-yoga";

const typeDefs = `
Query {
  hello(name: String): String!
}
`

const resolvers = {
  Query: {
    hello: () => {
      return ""
    },
  },
}

const server = new GraphQLServer({ typeDefs, resolvers })

server.start().then(server => {
  console.log("started server at %s", server.address())
})

โฏ yarn -s tsc --project tsconfig.json
node_modules/subscriptions-transport-ws/dist/server.d.ts:2:28 - error TS7016: Could not find a declaration file for module 'ws'. '/Users/jasonkuhrt/projects/personal/test/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';`

2 import * as WebSocket from 'ws';
                             ~~~~


error Command failed with exit code 2.

I realize this might be an upstream issue. Anyone else hitting this?

statustale

Most helpful comment

I encountered the same issue.
You'll be able to fix it getting ws module type definition by manually.

yarn add @types/ws -D

All 7 comments

I encountered the same issue.
You'll be able to fix it getting ws module type definition by manually.

yarn add @types/ws -D

Hi @joe-re
That doesn't work.

In my case, I'm not sure if it's related to graphql-yoga or not but this is my error message.
image

I'm using this boilerplate + yarn workspaces

Can you try yarn add ws?

Due to inactivity of this issue we have marked it stale. It will be closed if no further activity occurs.

Hey :wave:, It seems like this issue has been inactive for some time. In need for maintaining clear overview of the issues concerning the latest version of graphql-yoga we'll close it.
Feel free to reopen it at any time if you believe we should futher discuss its content. :slightly_smiling_face:

Hey @rohmanhm , can you try add this in your typescript configuration file. "noImplicitAny": false

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ramonmulia picture ramonmulia  ยท  3Comments

cj picture cj  ยท  3Comments

AhmadEl-Banna picture AhmadEl-Banna  ยท  5Comments

joshhopkins picture joshhopkins  ยท  3Comments

CaptainChemist picture CaptainChemist  ยท  4Comments