Skip to content
This repository was archived by the owner on Jun 26, 2023. It is now read-only.

Type error consuming events #227

Closed
Tracked by #4114
wemeetagain opened this issue Jun 9, 2022 · 1 comment · Fixed by #230
Closed
Tracked by #4114

Type error consuming events #227

wemeetagain opened this issue Jun 9, 2022 · 1 comment · Fixed by #230
Labels

Comments

@wemeetagain
Copy link
Member

Consuming the events in a downstream library results in a type error:

Example

@chainsafe/lodestar: ../../node_modules/@libp2p/interfaces/dist/src/events.d.ts:18:5 - error TS2416: Property 'addEventListener' in type 'EventEmitter<EventMap>' is not assignable to the same property in base type 'EventTarget'.
@chainsafe/lodestar:   Type '<U extends keyof EventMap>(type: U, callback: EventHandler<EventMap[U]>, options?: boolean | AddEventListenerOptions | undefined) => void' is not assignable to type '(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions | undefined) => void'.
@chainsafe/lodestar:     Types of parameters 'type' and 'type' are incompatible.
@chainsafe/lodestar:       Type 'string' is not assignable to type 'keyof EventMap'.
@chainsafe/lodestar: 18     addEventListener<U extends keyof EventMap>(type: U, callback: EventHandler<EventMap[U]>, options?: AddEventListenerOptions | boolean): void;
@chainsafe/lodestar:        ~~~~~~~~~~~~~~~~
@chainsafe/lodestar: ../../node_modules/@libp2p/interfaces/dist/src/events.d.ts:19:5 - error TS2416: Property 'removeEventListener' in type 'EventEmitter<EventMap>' is not assignable to the same property in base type 'EventTarget'.
@chainsafe/lodestar:   Type '<U extends keyof EventMap>(type: U, callback?: EventHandler<EventMap[U]> | undefined, options?: boolean | EventListenerOptions | undefined) => void' is not assignable to type '(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions | undefined) => void'.
@chainsafe/lodestar:     Types of parameters 'type' and 'type' are incompatible.
@chainsafe/lodestar:       Type 'string' is not assignable to type 'keyof EventMap'.
@chainsafe/lodestar: 19     removeEventListener<U extends keyof EventMap>(type: U, callback?: EventHandler<EventMap[U]> | undefined, options?: EventListenerOptions | boolean): void;
@chainsafe/lodestar:        ~~~~~~~~~~~~~~~~~~~

achingbrain added a commit that referenced this issue Jun 11, 2022
Specify what `EventMap` should look like in the generic type.

Fixes: #227
achingbrain added a commit that referenced this issue Jun 14, 2022
Specify what `EventMap` should look like in the generic type.

Fixes: #227
github-actions bot pushed a commit that referenced this issue Jun 14, 2022
## [@libp2p/interfaces-v2.0.4](https://github.com/libp2p/js-libp2p-interfaces/compare/@libp2p/interfaces-v2.0.3...@libp2p/interfaces-v2.0.4) (2022-06-14)

### Bug Fixes

* event emitter types ([#230](#230)) ([f16f74f](f16f74f)), closes [#227](#227)

### Trivial Changes

* add missing deps ([#229](#229)) ([cc3cece](cc3cece))
@github-actions
Copy link

🎉 This issue has been resolved in version @libp2p/interfaces-v2.0.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant