From 8fbb5c4ad1600271cd49bf008fb26ef31f1b5fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Thu, 26 Aug 2021 23:50:26 +0200 Subject: [PATCH] Fix imapfilter typing --- mod.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mod.ts b/mod.ts index 18faa9f..c2c0eb8 100644 --- a/mod.ts +++ b/mod.ts @@ -341,17 +341,16 @@ export function ifilter( /** * Apply map, and filter invalid results in the same pass. */ -export function imapfilter( +export function imapfilter( iterable: Iterable, - mapfunc: (_: T1) => Exclude | typeof exclusion, - exclusion: E = null as unknown as E, -): Iterable { + mapfunc: (_: T1) => T2 | null, +): Iterable> { return { [Symbol.iterator]: function* () { for (let value of iterable) { const mapped = mapfunc(value); - if (mapped !== exclusion) { - yield mapped as T2; + if (mapped !== null) { + yield mapped as Exclude; } } },