obs-websocket-community-projects / obs-websocket-js

Consumes https://github.com/obsproject/obs-websocket
MIT License
679 stars 96 forks source link

Cannot use namespace 'EventEmitter' as a type. #335

Closed YpsilonTM closed 9 months ago

YpsilonTM commented 1 year ago

So this is my code and I keep getting the error that EventEmitter cannot be used as a type. I remove my node modules folder did a clean install. Anyone have a clue why it keeps complaining about that?

import OBSWebSocket from 'obs-websocket-js'
import { OBS_SETTINGS } from '../config.js'

class OBS {
  private socketURL: string
  private socket: OBSWebSocket

  constructor() {
    this.socketURL = OBS_SETTINGS.getSocketURL()
  }

  public async connect() {
    this.socket = new OBSWebSocket()
    return await this.socket.connect(this.socketURL)
  }
}

The Error:

node_modules/obs-websocket-js/dist/base.d.ts:23:56 - error TS2507: Type 'typeof import("D:/Development/silon-server-twitch/node_modules/eventemitter3/index")' is not a constructor function type.

23 export declare abstract class BaseOBSWebSocket extends EventEmitter<MapValueToArgsArray<EventTypes>> {
                                                          ~~~~~~~~~~~~

node_modules/obs-websocket-js/dist/base.d.ts:27:34 - error TS2709: Cannot use namespace 'EventEmitter' as a type.

27     protected internalListeners: EventEmitter<string | symbol, any>;
                                    ~~~~~~~~~~~~

Found 2 errors in the same file, starting at: node_modules/obs-websocket-js/dist/base.d.ts:23

Versions Used:

YpsilonTM commented 1 year ago

Nevermind i thought it was just ignorable with: "skipLibCheck": true,

But it breaks al typescript types for me. I was comparing with my previous working version and there EventEmitter3 was on V4. Somehow V5 broke stuff for me.

YpsilonTM commented 1 year ago

So it actually not fixed.

YpsilonTM commented 1 year ago

in node_modules\obs-websocket-js\dist\base.d.ts adjusting import EventEmitter from 'eventemitter3'; to import { EventEmitter } from 'eventemitter3';

I saw its exported as default and named. So gave that a try still don't get why it then works.

fixed all the typescript complaining for me. And I have my types back.

Hoishin commented 1 year ago

in node_modules\obs-websocket-js\dist\base.d.ts adjusting

import EventEmitter from 'eventemitter3';

to

import { EventEmitter } from 'eventemitter3';

I saw its exported as default and named. So gave that a try still don't get why it then works.

fixed all the typescript complaining for me. And I have my types back.

This is already fixed in the repo but has not been published yet.

YpsilonTM commented 9 months ago

Ok thank you maybe one day I will see the next release.

mint-dewit commented 9 months ago

@Hoishin is it possible to get this published? it is quite annoying.

Hoishin commented 9 months ago

@mint-dewit I'm not maintainer of this repo/package

t2t2 commented 9 months ago

Published 5.0.4 which includes #333