Skip to content

Commit c7d3036

Browse files
authoredMar 13, 2024··
ReadonlyArray: fix sort signature, closes #2301 (#2303)
1 parent bce21c5 commit c7d3036

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed
 

‎.changeset/swift-pugs-train.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"effect": patch
3+
---
4+
5+
ReadonlyArray: fix `sort` signature, closes #2301

‎packages/effect/dtslint/ReadonlyArray.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as Effect from "effect/Effect"
22
import * as Equal from "effect/Equal"
33
import { hole, identity, pipe } from "effect/Function"
44
import * as Option from "effect/Option"
5-
import type * as Order from "effect/Order"
5+
import * as Order from "effect/Order"
66
import * as Predicate from "effect/Predicate"
77
import * as ReadonlyArray from "effect/ReadonlyArray"
88

@@ -216,6 +216,15 @@ pipe(nonEmptyabs, ReadonlyArray.sort(ordera))
216216
// $ExpectType [AB, ...AB[]]
217217
ReadonlyArray.sort(ordera)(nonEmptyabs)
218218

219+
// @ts-expect-error
220+
pipe([1], ReadonlyArray.sort(Order.string))
221+
222+
// @ts-expect-error
223+
ReadonlyArray.sort([1], Order.string)
224+
225+
// @ts-expect-error
226+
ReadonlyArray.sort(Order.string)([1])
227+
219228
// -------------------------------------------------------------------------------------
220229
// sortWith
221230
// -------------------------------------------------------------------------------------

‎packages/effect/src/ReadonlyArray.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ export const reverse = <S extends Iterable<any> | NonEmptyReadonlyArray<any>>(
883883
export const sort: {
884884
<B>(
885885
O: Order.Order<B>
886-
): <S extends ReadonlyArray<any> | Iterable<any>>(self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S>>
886+
): <A extends B, S extends ReadonlyArray<A> | Iterable<A>>(self: S) => ReadonlyArray.With<S, ReadonlyArray.Infer<S>>
887887
<A extends B, B>(self: NonEmptyReadonlyArray<A>, O: Order.Order<B>): NonEmptyArray<A>
888888
<A extends B, B>(self: Iterable<A>, O: Order.Order<B>): Array<A>
889889
} = dual(2, <A extends B, B>(self: Iterable<A>, O: Order.Order<B>): Array<A> => {

0 commit comments

Comments
 (0)
Please sign in to comment.