From f934dc77431904217765f53e963f50311ddd69af Mon Sep 17 00:00:00 2001 From: Levin Keller Date: Fri, 11 Aug 2023 00:42:52 +0200 Subject: [PATCH] fix: declare that of returns arrays of length 1 --- docs/modules/Array.ts.md | 2 +- docs/modules/NonEmptyArray.ts.md | 2 +- dtslint/ts3.5/Array.ts | 2 ++ package-lock.json | 4 ++-- src/Array.ts | 2 +- src/NonEmptyArray.ts | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/modules/Array.ts.md b/docs/modules/Array.ts.md index c6ec536a54..cc2d65fa72 100644 --- a/docs/modules/Array.ts.md +++ b/docs/modules/Array.ts.md @@ -238,7 +238,7 @@ element of the base type (this is useful for building a `Monad`). **Signature** ```ts -export declare const of: (a: A) => A[] +export declare const of: (a: A) => [A] ``` **Example** diff --git a/docs/modules/NonEmptyArray.ts.md b/docs/modules/NonEmptyArray.ts.md index 1e1ffaab05..55b19a0a08 100644 --- a/docs/modules/NonEmptyArray.ts.md +++ b/docs/modules/NonEmptyArray.ts.md @@ -176,7 +176,7 @@ Added in v2.11.0 **Signature** ```ts -export declare const of: (a: A) => NonEmptyArray +export declare const of: (a: A) => [A] ``` Added in v2.0.0 diff --git a/dtslint/ts3.5/Array.ts b/dtslint/ts3.5/Array.ts index 3d28509229..004b0de6af 100644 --- a/dtslint/ts3.5/Array.ts +++ b/dtslint/ts3.5/Array.ts @@ -9,6 +9,8 @@ declare const ns: Array declare const ss: Array declare const tns: Array<[number, string]> +pipe(_.of('b'), ([value]: [string]) => value) + // prepend pipe(ss, _.prepend('a')) // $ExpectType NonEmptyArray diff --git a/package-lock.json b/package-lock.json index d9d89a850a..74b4a7ce69 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "fp-ts", - "version": "2.15.0", + "version": "2.16.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "fp-ts", - "version": "2.15.0", + "version": "2.16.1", "license": "MIT", "devDependencies": { "@effect/language-service": "^0.0.19", diff --git a/src/Array.ts b/src/Array.ts index 1668856aa8..45b26d016a 100644 --- a/src/Array.ts +++ b/src/Array.ts @@ -1508,7 +1508,7 @@ const _chainRecBreadthFirst: ChainRec1['chainRec'] = RA._chainRecBreadthFir * @category constructors * @since 2.0.0 */ -export const of: (a: A) => Array = NEA.of +export const of: (a: A) => [A] = NEA.of /** * Makes an empty `Array`, useful for building a [`Monoid`](#Monoid) diff --git a/src/NonEmptyArray.ts b/src/NonEmptyArray.ts index 4a135abcd2..8f9b7a25cc 100644 --- a/src/NonEmptyArray.ts +++ b/src/NonEmptyArray.ts @@ -464,7 +464,7 @@ export const copy: (as: NonEmptyArray) => NonEmptyArray = fromReadonlyN * @category constructors * @since 2.0.0 */ -export const of: (a: A) => NonEmptyArray = (a) => [a] +export const of: (a: A) => [A] = (a) => [a] /** * @since 2.5.1