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: declare that of returns arrays of length 1 #1901

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Author

@levino levino Aug 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This created a TS error before below fixes.


// 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