diff --git a/CHANGELOG.md b/CHANGELOG.md index 9071db5c8..e2b0138a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,11 @@ **Note**: A feature tagged as Experimental is in a high state of flux, you're at risk of it changing without notice. +# 2.9.4 + +- **Bug Fix** + - fix `filter` overloads in `NonEmptyArray` / `ReadonlyNonEmptyArray`, closes #1388 (@gcanti) + # 2.9.3 - **Polish** diff --git a/docs/modules/NonEmptyArray.ts.md b/docs/modules/NonEmptyArray.ts.md index a91195ac9..afb2ef526 100644 --- a/docs/modules/NonEmptyArray.ts.md +++ b/docs/modules/NonEmptyArray.ts.md @@ -353,7 +353,7 @@ Added in v2.0.0 ```ts export declare function filter( refinement: Refinement -): (nea: NonEmptyArray) => Option> +): (nea: NonEmptyArray) => Option> export declare function filter(predicate: Predicate): (nea: NonEmptyArray) => Option> ``` diff --git a/docs/modules/ReadonlyNonEmptyArray.ts.md b/docs/modules/ReadonlyNonEmptyArray.ts.md index d1a75edb1..39cdf26c0 100644 --- a/docs/modules/ReadonlyNonEmptyArray.ts.md +++ b/docs/modules/ReadonlyNonEmptyArray.ts.md @@ -913,7 +913,7 @@ Added in v2.6.3 ```ts export declare function filter( refinement: Refinement -): (nea: ReadonlyNonEmptyArray) => Option> +): (nea: ReadonlyNonEmptyArray) => Option> export declare function filter( predicate: Predicate ): (nea: ReadonlyNonEmptyArray) => Option> diff --git a/dtslint/ts3.5/NonEmptyArray.ts b/dtslint/ts3.5/NonEmptyArray.ts index 59c95c054..8afd17eac 100644 --- a/dtslint/ts3.5/NonEmptyArray.ts +++ b/dtslint/ts3.5/NonEmptyArray.ts @@ -2,7 +2,6 @@ import * as _ from '../../src/NonEmptyArray' import { Ord } from '../../src/Ord' import { pipe } from '../../src/function' -declare const as: Array declare const neas: _.NonEmptyArray declare const nens: _.NonEmptyArray declare const netns: _.NonEmptyArray<[number, string]> @@ -89,3 +88,20 @@ pipe( _.bind('a', () => _.of(1)), _.bind('b', () => _.of('b')) ) + +// +// filter +// + +declare const isNumber1: (sn: string | number) => sn is number +declare const isNumber2: (sn: unknown) => sn is number +declare const neasn: _.NonEmptyArray + +// $ExpectType Option> +pipe(neasn, _.filter(isNumber1)) +// $ExpectType Option> +_.filter(isNumber1)(neasn) +// $ExpectType Option> +pipe(neasn, _.filter(isNumber2)) +// $ExpectType Option> +_.filter(isNumber2)(neasn) diff --git a/dtslint/ts3.5/ReadonlyNonEmptyArray.ts b/dtslint/ts3.5/ReadonlyNonEmptyArray.ts index 42ab1843a..f0057b2da 100644 --- a/dtslint/ts3.5/ReadonlyNonEmptyArray.ts +++ b/dtslint/ts3.5/ReadonlyNonEmptyArray.ts @@ -89,3 +89,20 @@ pipe( _.bind('a', () => _.of(1)), _.bind('b', () => _.of('b')) ) + +// +// filter +// + +declare const isNumber1: (sn: string | number) => sn is number +declare const isNumber2: (sn: unknown) => sn is number +declare const neasn: _.ReadonlyNonEmptyArray + +// $ExpectType Option> +pipe(neasn, _.filter(isNumber1)) +// $ExpectType Option> +_.filter(isNumber1)(neasn) +// $ExpectType Option> +pipe(neasn, _.filter(isNumber2)) +// $ExpectType Option> +_.filter(isNumber2)(neasn) diff --git a/package.json b/package.json index 8cc7bf7ef..8c55e8453 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fp-ts", - "version": "2.9.3", + "version": "2.9.4", "description": "Functional programming in TypeScript", "main": "lib/index.js", "module": "es6/index.js", diff --git a/src/NonEmptyArray.ts b/src/NonEmptyArray.ts index 1f550158a..5f3973011 100644 --- a/src/NonEmptyArray.ts +++ b/src/NonEmptyArray.ts @@ -283,7 +283,7 @@ export function copy(nea: NonEmptyArray): NonEmptyArray { */ export function filter( refinement: Refinement -): (nea: NonEmptyArray) => Option> +): (nea: NonEmptyArray) => Option> export function filter(predicate: Predicate): (nea: NonEmptyArray) => Option> export function filter(predicate: Predicate): (nea: NonEmptyArray) => Option> { return RNEA.filter(predicate) as any diff --git a/src/ReadonlyNonEmptyArray.ts b/src/ReadonlyNonEmptyArray.ts index 46e041d34..d795e0ab1 100644 --- a/src/ReadonlyNonEmptyArray.ts +++ b/src/ReadonlyNonEmptyArray.ts @@ -343,7 +343,7 @@ export function modifyAt( */ export function filter( refinement: Refinement -): (nea: ReadonlyNonEmptyArray) => Option> +): (nea: ReadonlyNonEmptyArray) => Option> export function filter(predicate: Predicate): (nea: ReadonlyNonEmptyArray) => Option> export function filter( predicate: Predicate