feat(stdlib): new modules + eslint/tsconfig migration
- Add array/async/etc. modules and type tests; migrate to eslint flat config and composite tsconfig (vitest typecheck enabled). - Fix PubSub.emit to snapshot listeners before iterating (stable EventEmitter semantics; avoids invoking listeners added during the same emit).
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { describe, expectTypeOf, it } from 'vitest';
|
||||
import { compose } from '.';
|
||||
|
||||
describe('compose', () => {
|
||||
it('infers the final return type through the chain', () => {
|
||||
const fn = compose((s: string) => s.length > 0, (n: number) => `${n}`, (n: number) => n + 1);
|
||||
|
||||
expectTypeOf(fn).parameters.toEqualTypeOf<[number]>();
|
||||
expectTypeOf(fn).returns.toEqualTypeOf<boolean>();
|
||||
});
|
||||
|
||||
it('keeps the variadic parameters of the last function', () => {
|
||||
const fn = compose((n: number) => `${n}`, (a: number, b: number) => a + b);
|
||||
|
||||
expectTypeOf(fn).parameters.toEqualTypeOf<[number, number]>();
|
||||
expectTypeOf(fn).returns.toEqualTypeOf<string>();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user