-
-
Notifications
You must be signed in to change notification settings - Fork 174
Open
Description
Screenshot

Expected Behaviour
My ts project does not compile when I use useServer from graphql-ws due to a typescript error in the definition file ws.d.ts.
It is fixed when I change line 2 to
import WebSocket, {WebSocketServer} from 'ws';
and delete line 8
Actual Behaviour
The project should compile
Debug Information
The error happens in node_modules/graphql-ws/dist/use/ws.d.ts
during ts compilation. My project does not contain any errors
Further Information
My project is type: module.
I tried downgrading ws, @types/ws and graphql-ws but the error was never fixed.
My compilerOptions
"compilerOptions": {
"target": "ES2020",
"module": "NodeNext",
"lib": ["es2020", "DOM"],
"moduleResolution": "nodenext",
"allowJs": true,
"outDir": "build",
"rootDir": ".",
"strict": true,
"noImplicitAny": false,
"esModuleInterop": true,
"sourceMap": true,
"allowUnreachableCode": true,
},
Here is the diff that solved my problem:
diff --git a/node_modules/graphql-ws/dist/use/ws.d.ts b/node_modules/graphql-ws/dist/use/ws.d.ts
index 60a0262..6ac0055 100644
--- a/node_modules/graphql-ws/dist/use/ws.d.ts
+++ b/node_modules/graphql-ws/dist/use/ws.d.ts
@@ -1,12 +1,10 @@
import * as http from 'http';
-import WebSocket from 'ws';
+import WebSocket, {WebSocketServer} from 'ws';
export { default as WebSocket } from 'ws';
import { b as ConnectionInitMessage, a as Disposable } from '../common-DY-PBNYy.js';
import { S as ServerOptions } from '../server-CvxoLxzz.js';
import 'graphql';
-type WebSocketServer = WebSocket.Server;
-
/**
* The extra that will be put in the `Context`.
*
Metadata
Metadata
Assignees
Labels
No labels