Skip to content

Doesn't compile #6

@a-yumashin

Description

@a-yumashin

Doesn't compile: points to line

const MyEventEmitter: MyEventEmitter = TsEventEmitter.create();

saying

ERROR in [at-loader] ./src/MyEventEmitter.tsx:10:7
TS2322: Type 'TsEventEmitter' is not assignable to type 'MyEventEmitter'.
Types of property 'event' are incompatible.
Type '(name: string) => Event' is not assignable to type '{ (name: "foo"): Event0; (name: "bar"): Event1<MyEventEmitter, string>;
(name: "b...'.
Type 'Event' is not assignable to type 'Event0'.
Property 'on' is missing in type 'Event'.

And what's the difference between

event(name: 'foo'): TsEventEmitter.Event0<this>;

and

event(name: string): TsEventEmitter.Event;

?

And particularly: is the first syntax used to specify the default value ('foo') of the name parameter of the event function? Or 'foo' isn't the default value? Or... event isn't a function at all?! Sorry, I'm completely new to TypeScript.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions