Skip to content

Commit

Permalink
fix: infer usages with 'as const' properly (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomerAberbach committed Feb 23, 2022
1 parent 208b61d commit 1e2ea32
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/collect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ type CollectorToCollection<
? WeakSet<Value>
: never
: C extends MapCollector
? Value extends [infer EntryKey, infer EntryValue]
? Value extends readonly [infer EntryKey, infer EntryValue]
? MapCollectorToCollection<C, EntryKey, EntryValue>
: never
: never
Expand Down
2 changes: 1 addition & 1 deletion src/curry.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Curried<Parameters extends ReadonlyArray<any>, Return> = <
...args: PartialParameters
) => PartialParameters extends Parameters
? Return
: Parameters extends [
: Parameters extends readonly [
...TupleOfSameLength<PartialParameters>,
...infer RemainingParameters
]
Expand Down
10 changes: 10 additions & 0 deletions test-d/collect.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import {
Collector,
folding,
grouping,
map,
MapCollector,
pipe,
toArray,
toMap,
toObject,
Expand Down Expand Up @@ -118,3 +120,11 @@ expectType<Record<string, string[]>>(
string,
][]),
)

expectType<Record<number, Set<number>>>(
pipe(
[1, 2, 3],
map(x => [x, x * 2] as const),
collect(grouping(toSet, toObject)),
),
)

0 comments on commit 1e2ea32

Please sign in to comment.