Could not find a declaration file for module 'ws'
See original GitHub issueI 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?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Could not find a declaration file for module 'module-name ...
In order for this to work, I had to make declare module '...' the first line of code in the module.d.ts file, and...
Read more >Could not find declaration file for module 'X' Error | bobbyhadz
The error "Could not find a declaration file for module" occurs when TypeScript cannot find the type declaration for a module. To solve...
Read more >How to fix error TS7016: Could not find a declaration file for ...
Try `npm install @types/XYZ` if it exists or add a new declaration (.d. · declare module 'XYZ';. Lastly, you also need to add...
Read more >Error: Could not find a declaration file for module - YouTube
Fix error: Could not find a declaration file for module ... implicitly has an 'any' type.Try npm install library-name if it exists or...
Read more >Fixing the TS7016 Error | Atomist Blog
4 Terrible Ways (and 4 Better Ways) to fix 'TS7016: Could not find declaration file' · Caveat: the compiler option --noEmitOnError makes ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I encountered the same issue. You’ll be able to fix it getting
ws
module type definition by manually.Hey @rohmanhm , can you try add this in your typescript configuration file.
"noImplicitAny": false