Skip to content

Commit

Permalink
fix: declare that of returns arrays of length 1
Browse files Browse the repository at this point in the history
  • Loading branch information
levino committed Aug 10, 2023
1 parent 01b8661 commit f934dc7
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/modules/Array.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) => A[]
export declare const of: <A>(a: A) => [A]
```
**Example**
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 @@ -176,7 +176,7 @@ Added in v2.11.0
**Signature**

```ts
export declare const of: <A>(a: A) => NonEmptyArray<A>
export declare const of: <A>(a: A) => [A]
```
Added in v2.0.0
Expand Down
2 changes: 2 additions & 0 deletions dtslint/ts3.5/Array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ declare const ns: Array<number>
declare const ss: Array<string>
declare const tns: Array<[number, string]>

pipe(_.of('b'), ([value]: [string]) => value)

// prepend

pipe(ss, _.prepend('a')) // $ExpectType NonEmptyArray<string>
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,7 @@ const _chainRecBreadthFirst: ChainRec1<URI>['chainRec'] = RA._chainRecBreadthFir
* @category constructors
* @since 2.0.0
*/
export const of: <A>(a: A) => Array<A> = NEA.of
export const of: <A>(a: A) => [A] = NEA.of

/**
* Makes an empty `Array`, useful for building a [`Monoid`](#Monoid)
Expand Down
2 changes: 1 addition & 1 deletion src/NonEmptyArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ export const copy: <A>(as: NonEmptyArray<A>) => NonEmptyArray<A> = fromReadonlyN
* @category constructors
* @since 2.0.0
*/
export const of: <A>(a: A) => NonEmptyArray<A> = (a) => [a]
export const of: <A>(a: A) => [A] = (a) => [a]

/**
* @since 2.5.1
Expand Down

0 comments on commit f934dc7

Please sign in to comment.