Skip to content

Class static side 'typeof Emitter' incorrectly extends base class static side 'typeof EventEmitter' #385

Closed

Description

@moltar

Describe the Bug

When building the project with TS, I get the following error:

node_modules/cloudevents/dist/transport/emitter.d.ts:48:22 - error TS2417: Class static side 'typeof Emitter' incorrectly extends base class static side 'typeof EventEmitter'.
  Types of property 'on' are incompatible.
    Type '(event: "newListener" | "removeListener" | "cloudevent", listener: (...args: any[]) => void) => void' is not assignable to type '(emitter: EventEmitter, event: string) => AsyncIterableIterator<any>'.
      Types of parameters 'event' and 'emitter' are incompatible.
        Type 'EventEmitter' is not assignable to type '"newListener" | "removeListener" | "cloudevent"'.
          Type 'EventEmitter' is not assignable to type '"cloudevent"'.

48 export declare class Emitter extends EventEmitter {
                       ~~~~~~~
    "cloudevents": "4.0.0",
    "@types/node": "14.14.27",
    "typescript": "4.1.3"

Steps to Reproduce

N/A

Expected Behavior

Build passing.

Additional context

    "cloudevents": "4.0.0",
    "@types/node": "14.14.27",
    "typescript": "4.1.3"

Activity

  1. lance commented on Feb 18, 2021

    @lance
    Member

    Hi @moltar if you could provide some steps to reproduce this, that would be great! Looking at the typescript example in this repository, I do not see this problem. Thanks. :)

  2. moltar commented on Feb 19, 2021

    @moltar
    Author
  3. danielgel commented on Feb 23, 2021

    @danielgel

    +1

  4. mnesbitt commented on Feb 24, 2021

    @mnesbitt

    I'm having this issue as well in version 4.0.0.

    I did some testing and it looks like it's caused by the version of @types/node being used. The typescript example in this repository is using @types/node@8.9.0 which is 3 years old. I'm currently using @types/node@14.14.10 and seeing the issue, and @moltar 's example is using 14.14 as well.

    I downgraded to cloudevents@3.2.0 for now and it's compiling for me with the latest @types/node.

  5. lance commented on Feb 25, 2021

    @lance
    Member

    @mnesbitt thanks for that info. I'll take a look.

  6. lance commented on Feb 25, 2021

    @lance
    Member

    @mnesbitt @moltar @hilfor if you all have an opportunity to test this change in your project and provide feedback, that would be appreciated. Thanks!

  7. moltar commented on Feb 26, 2021

    @moltar
    Author

    @lance can we get a pre-release or an alpha channel release? It's not easy to test this, because the code needs to be transpiled to be recognized by NPM.

    I installed it from the PR:

    npm install cloudevents/sdk-javascript#pull/387/head
    

    But the dir does not have the packaged files:

    ❯ tree node_modules/cloudevents
    node_modules/cloudevents
    ├── CHANGELOG.md
    ├── LICENSE
    ├── README.md
    └── package.json
    
  8. moltar commented on Feb 26, 2021

    @moltar
    Author
  9. lance commented on Mar 3, 2021

    @lance
    Member

    @moltar thanks for bringing this up.

    Given that this is a community repo with established processes, we'll need to discuss it. But I think it is a good suggestion. I've opened an issue to track this #388.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions