Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix filter overloads in NonEmptyArray / ReadonlyNonEmptyArray, … #1390

Merged
merged 1 commit into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/NonEmptyArray.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ Added in v2.0.0
```ts
export declare function filter<A, B extends A>(
refinement: Refinement<A, B>
): (nea: NonEmptyArray<A>) => Option<NonEmptyArray<A>>
): (nea: NonEmptyArray<A>) => Option<NonEmptyArray<B>>
export declare function filter<A>(predicate: Predicate<A>): (nea: NonEmptyArray<A>) => Option<NonEmptyArray<A>>
```

Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ReadonlyNonEmptyArray.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ Added in v2.6.3
```ts
export declare function filter<A, B extends A>(
refinement: Refinement<A, B>
): (nea: ReadonlyNonEmptyArray<A>) => Option<ReadonlyNonEmptyArray<A>>
): (nea: ReadonlyNonEmptyArray<A>) => Option<ReadonlyNonEmptyArray<B>>
export declare function filter<A>(
predicate: Predicate<A>
): (nea: ReadonlyNonEmptyArray<A>) => Option<ReadonlyNonEmptyArray<A>>
Expand Down
18 changes: 17 additions & 1 deletion dtslint/ts3.5/NonEmptyArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as _ from '../../src/NonEmptyArray'
import { Ord } from '../../src/Ord'
import { pipe } from '../../src/function'

declare const as: Array<string>
declare const neas: _.NonEmptyArray<string>
declare const nens: _.NonEmptyArray<number>
declare const netns: _.NonEmptyArray<[number, string]>
Expand Down Expand Up @@ -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<string | number>

// $ExpectType Option<NonEmptyArray<number>>
pipe(neasn, _.filter(isNumber1))
// $ExpectType Option<NonEmptyArray<number>>
_.filter(isNumber1)(neasn)
// $ExpectType Option<NonEmptyArray<number>>
pipe(neasn, _.filter(isNumber2))
// $ExpectType Option<NonEmptyArray<number>>
_.filter(isNumber2)(neasn)
17 changes: 17 additions & 0 deletions dtslint/ts3.5/ReadonlyNonEmptyArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string | number>

// $ExpectType Option<ReadonlyNonEmptyArray<number>>
pipe(neasn, _.filter(isNumber1))
// $ExpectType Option<ReadonlyNonEmptyArray<number>>
_.filter(isNumber1)(neasn)
// $ExpectType Option<ReadonlyNonEmptyArray<number>>
pipe(neasn, _.filter(isNumber2))
// $ExpectType Option<ReadonlyNonEmptyArray<number>>
_.filter(isNumber2)(neasn)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/NonEmptyArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ export function copy<A>(nea: NonEmptyArray<A>): NonEmptyArray<A> {
*/
export function filter<A, B extends A>(
refinement: Refinement<A, B>
): (nea: NonEmptyArray<A>) => Option<NonEmptyArray<A>>
): (nea: NonEmptyArray<A>) => Option<NonEmptyArray<B>>
export function filter<A>(predicate: Predicate<A>): (nea: NonEmptyArray<A>) => Option<NonEmptyArray<A>>
export function filter<A>(predicate: Predicate<A>): (nea: NonEmptyArray<A>) => Option<NonEmptyArray<A>> {
return RNEA.filter(predicate) as any
Expand Down
2 changes: 1 addition & 1 deletion src/ReadonlyNonEmptyArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ export function modifyAt<A>(
*/
export function filter<A, B extends A>(
refinement: Refinement<A, B>
): (nea: ReadonlyNonEmptyArray<A>) => Option<ReadonlyNonEmptyArray<A>>
): (nea: ReadonlyNonEmptyArray<A>) => Option<ReadonlyNonEmptyArray<B>>
export function filter<A>(predicate: Predicate<A>): (nea: ReadonlyNonEmptyArray<A>) => Option<ReadonlyNonEmptyArray<A>>
export function filter<A>(
predicate: Predicate<A>
Expand Down