Skip to content

Commit

Permalink
Fix compatibility with p-event (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
younggglcy committed Feb 13, 2024
1 parent 253f457 commit 2eea7f7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
36 changes: 18 additions & 18 deletions index.test-d.ts
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-empty-function, @typescript-eslint/no-floating-promises */
import {expectType, expectError, expectNotAssignable, expectAssignable} from 'tsd';
import {pEvent} from 'p-event';
import {pEventIterator} from 'p-event';
import Emittery from './index.js';

type AnyListener = (eventData?: unknown) => void | Promise<void>;
Expand Down Expand Up @@ -254,26 +254,26 @@ type AnyListener = (eventData?: unknown) => void | Promise<void>;
};
}

// TODO: Fix type compatibility with `p-event`.
// Compatibility with p-event, without explicit types
// {
// const ee = new Emittery();
// pEvent.iterator(ee, 'data', {
// resolutionEvents: ['finish']
// });
// }
{
const ee = new Emittery();
pEventIterator(ee, 'data', {
resolutionEvents: ['finish'],
});
}

// Compatibility with p-event, with explicit types
// {
// const ee = new Emittery<{
// data: unknown;
// error: unknown;
// finish: undefined;
// }>();
// pEvent.iterator(ee, 'data', {
// resolutionEvents: ['finish']
// });
// }
{
type EventData = {
data: unknown;
error: unknown;
finish: undefined;
};
const ee = new Emittery<EventData>();
pEventIterator<keyof EventData, unknown>(ee, 'data', {
resolutionEvents: ['finish'],
});
}

// Mixin type
Emittery.mixin('emittery')(class {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -57,7 +57,7 @@
"ava": "^4.3.3",
"delay": "^5.0.0",
"nyc": "^15.1.0",
"p-event": "^5.0.1",
"p-event": "^6.0.0",
"tsd": "^0.23.0",
"xo": "^0.55.0"
},
Expand Down

0 comments on commit 2eea7f7

Please sign in to comment.