js-stellar-sdk icon indicating copy to clipboard operation
js-stellar-sdk copied to clipboard

Interface 'Event' incorrectly extends interface (Type 'boolean' is not assignable to type '() => void')

Open bilal-baig-kryptomind opened this issue 2 years ago • 2 comments

Describe the bug There is an issue that is coming from node modules when creating build in nest js. Here is the path of the file from where the issue is coming from node_modules/stellar-sdk/types/dom-monkeypatch.d.ts:111:11 - error TS2430:

The descriptive Error message is:

node_modules/stellar-sdk/types/dom-monkeypatch.d.ts:111:11 - error TS2430: Interface 'Event' incorrectly extends interface '{ readonly bubbles: boolean; cancelBubble: () => void; readonly cancelable: boolean; readonly composed: boolean; composedPath(): [EventTarget?]; readonly currentTarget: EventTarget; ... 10 more ...; readonly type: string; }'. Types of property 'cancelBubble' are incompatible. Type 'boolean' is not assignable to type '() => void'.

111 interface Event { ~~~~~

Found 1 error(s).

What version are you on? I tried with different version from 10.4.1 to downgrading to 10.1.2 and also same with version 9.

To Reproduce Steps to reproduce the behavior:

  1. Setup stellar sdk in nest js
  2. Run yarn build or npm run build (build will create successfully though but will throw error that is mentioned above)

Expected behavior It should not throw error while creating build.

bilal-baig-kryptomind avatar Apr 05 '23 14:04 bilal-baig-kryptomind

Any update on this, I am having this same issue and more:


6     onerror?: (event: MessageEvent) => void;
                        ~~~~~~~~~~~~

node_modules/stellar-sdk/types/dom-monkeypatch.d.ts:11:12 - error TS2304: Cannot find name 'MessageEvent'.

11   message: MessageEvent;
              ~~~~~~~~~~~~

node_modules/stellar-sdk/types/dom-monkeypatch.d.ts:17:39 - error TS2304: Cannot find name 'MessageEvent'.

17   onmessage: ((this: EventSource, ev: MessageEvent) => any) | null;
                                         ~~~~~~~~~~~~

node_modules/stellar-sdk/types/dom-monkeypatch.d.ts:111:11 - error TS2430: Interface 'Event' incorrectly extends interface '{ readonly bubbles: boolean; cancelBubble: () => void; readonly cancelable: boolean; readonly composed: boolean; composedPath(): [(EventTarget | undefined)?]; readonly currentTarget: EventTarget | null; ... 10 more ...; readonly type: string; }'.
  The types returned by 'composedPath()' are incompatible between these types.
    Type 'EventTarget[]' is not assignable to type '[(EventTarget | undefined)?]'.
      Target allows only 1 element(s) but source may have more.

111 interface Event {
              ~~~~~


Found 4 errors in 2 files.

Errors  Files
     1  node_modules/stellar-sdk/lib/horizon/call_builder.d.ts:6
     3  node_modules/stellar-sdk/types/dom-monkeypatch.d.ts:11```

CITGuru avatar Jan 29 '24 10:01 CITGuru

I solved this issue by following the steps in this comment: https://github.com/exceljs/exceljs/issues/1191#issuecomment-607121744

If you find other errors, you basically need to add other types and libs to your tsconfig.json.

{
    "lib": ["dom"],
    "types": ["node", "jest"],
}

I also needed the dom lib because of a issue with MessageEvent

paulormnas avatar Jun 06 '24 14:06 paulormnas