tiagosiebler / binance

Node.js & JavaScript SDK for Binance REST APIs & WebSockets, with TypeScript & browser support, integration tests, beautification & more.
MIT License
751 stars 266 forks source link

Property 'setMaxListeners' does not exist on type 'WebsocketClient'.ts(2339) #440

Open capaj opened 1 month ago

capaj commented 1 month ago

incorrect TS types: WebsocketClient instance extends event emitter at runtime, types do not. This ts-expect-error should not be necessary image

tiagosiebler commented 1 month ago

Can you rephrase the question?

capaj commented 1 month ago

I tried to rephrase the title. Was that what you meant?

tiagosiebler commented 1 month ago

No, the issue you are reporting is not clear to me, maybe I haven't had enough coffee yet today. I have no issues calling setMaxListeners.

capaj commented 1 month ago

are you using typescript? For me it is saying this image

I have the binance 2.12.2

tiagosiebler commented 1 month ago

Oddly enough, if I test this in the examples folder, I don't have that issue:

Screenshot 2024-08-09 at 10 05 29

I've also tried it in a separate project, with the latest version of this SDK imported, and no issue there either - runs without issues:

Screenshot 2024-08-09 at 10 08 32

No build warnings either...

tiagosiebler commented 1 month ago

Could you reproduce this issue in a really tiny ts project?

capaj commented 1 month ago

I am using bun, this is my tsconfig

{
  "compilerOptions": {
    "module": "ESNext",
    "esModuleInterop": true,
    "target": "ESNext",
    "moduleResolution": "Bundler",
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "isolatedModules": false,
    "strict": true,
    "noImplicitAny": true,
    "noEmit": true,
    "useUnknownInCatchVariables": false,
    "skipLibCheck": true,
    "inlineSourceMap": true,
    "resolveJsonModule": true,
    "types": ["bun-types"]
  },

  "exclude": ["dashboard/"],
  "lib": ["esnext", "es2021"]
}

that could mess up with those event listener types, will try to create a repro or I can invite you to the private repo where I have it

tiagosiebler commented 1 month ago

Interesting, could also be bun itself - would be curious to understand what's happening here and how to resolve it. Ideal would be to create a really tiny project with no real code in it to reproduce it - just the few lines causing this and the minimal boilerplate required (such as the tsconfig) to reproduce it. Then we start chopping away until we find what's causing it.