Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💥 Remove Emitter.listeners type clash #50

Merged
merged 1 commit into from
Jun 28, 2023
Merged

💥 Remove Emitter.listeners type clash #50

merged 1 commit into from
Jun 28, 2023

Conversation

alecgibson
Copy link
Collaborator

At the moment, since @ts-expect-error doesn't apply to type definitions, we get a downstream compilation error:

TS2416: Property 'listeners' in type 'Emitter' is not assignable to the same property in base type 'EventEmitter<string, any>'.
  Type 'Record<string, { node: Node; handler: Function; }[]>' is not assignable to type '<T extends string>(event: T) => ((...args: any[]) => void)[]'.
    Type 'Record<string, { node: Node; handler: Function; }[]>' provides no match for the signature '<T extends string>(event: T): ((...args: any[]) => void)[]'.

19     listeners: Record<string, {

This change removes the clash by renaming the internal variable. Note that, since listeners is public, this is technically breaking.

At the moment, since `@ts-expect-error` [doesn't apply][1] to type
definitions, we get a downstream compilation error:

```
TS2416: Property 'listeners' in type 'Emitter' is not assignable to the same property in base type 'EventEmitter<string, any>'.
  Type 'Record<string, { node: Node; handler: Function; }[]>' is not assignable to type '<T extends string>(event: T) => ((...args: any[]) => void)[]'.
    Type 'Record<string, { node: Node; handler: Function; }[]>' provides no match for the signature '<T extends string>(event: T): ((...args: any[]) => void)[]'.

19     listeners: Record<string, {
```

This change removes the clash by renaming the internal variable. Note
that, since `listeners` is `public`, this is technically breaking.

[1]: microsoft/TypeScript#38628
@alecgibson alecgibson merged commit f7f2071 into main Jun 28, 2023
@alecgibson alecgibson deleted the fix-listeners branch June 28, 2023 14:38
@luin
Copy link

luin commented Jan 14, 2024

FYI this has been fixed in slab@e227f35.

@alecgibson
Copy link
Collaborator Author

Thanks @luin !

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

Successfully merging this pull request may close these issues.

3 participants