Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TypedEventEmitter: update emit fuction signature
Summary: Somehow I cannot typecheck progress data with the union type: const onProgress = (progress: OperationProgress) => { // progressEmitter is TypedEventEmitter<'progress', OperationProgress> this.progressEmitter.emit('progress', progress); ^^^^^^^^^^^^^^^^^^^^ }; Error: Argument of type '["progress", OperationProgress]' is not assignable to parameter of type '[event: "error", data: Error] | [event: "progress", data: { id: string; kind: "queue"; queue: string[]; }] | [event: "progress", data: { id: string; kind: "spawn"; queue: string[]; }] | [event: "progress", data: { id: string; kind: "stderr"; message: string; }] | ... 5 more ... | [event: ...]'. Type '["progress", OperationProgress]' is not assignable to type '[event: "progress", data: { id: string; kind: "queue"; queue: string[]; }] | [event: "progress", data: { id: string; kind: "spawn"; queue: string[]; }] | [event: "progress", data: { id: string; kind: "stderr"; message: string; }] | [event: "progress", data: { ...; }] | ... 4 more ... | [event: ...]'. Type '["progress", OperationProgress]' is not assignable to type '[event: "progress", data: { id: string; kind: "forgot"; }]'. Type at position 1 in source is not compatible with type at position 1 in target. Type 'OperationProgress' is not assignable to type '{ id: string; kind: "forgot"; }'. Type '{ id: string; kind: "queue"; queue: string[]; }' is not assignable to type '{ id: string; kind: "forgot"; }'. Types of property 'kind' are incompatible. Type '"queue"' is not assignable to type '"forgot"'.ts(2345) This diff changes the signature to make it easier for tsc to understand. Reviewed By: evangrayk Differential Revision: D54364589 fbshipit-source-id: 841dd82449d1b21a2287b3a36b755b081094280d
- Loading branch information