Skip to content

Commit

Permalink
fix: DeepMutable tuples (#2879)
Browse files Browse the repository at this point in the history
  • Loading branch information
TylorS authored May 30, 2024
1 parent e83e4f5 commit cc8ac50
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/thin-bears-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": patch
---

Support tuples in Types.DeepMutable
3 changes: 3 additions & 0 deletions packages/effect/dtslint/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ hole<Types.DeepMutable<ReadonlyMap<TaggedValues<string>, ReadonlySet<TaggedValue
// $ExpectType { _tag: string; value: { _tag: string; value: { _tag: string; value: boolean[]; }[]; }[]; }[]
hole<Types.DeepMutable<ReadonlyArray<TaggedValues<TaggedValues<TaggedValues<boolean>>>>>>()

// $ExpectType [string, number, boolean]
hole<Types.DeepMutable<readonly [string, number, boolean]>>()

// -------------------------------------------------------------------------------------
// MatchRecord
// -------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion packages/effect/src/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export type Mutable<T> = {
*/
export type DeepMutable<T> = T extends ReadonlyMap<infer K, infer V> ? Map<DeepMutable<K>, DeepMutable<V>>
: T extends ReadonlySet<infer V> ? Set<DeepMutable<V>>
: T extends ReadonlyArray<infer V> ? Array<DeepMutable<V>>
: T extends ReadonlyArray<any> ? { -readonly [K in keyof T]: DeepMutable<T[K]> }
: [keyof T] extends [never] ? T
: { -readonly [K in keyof T]: DeepMutable<T[K]> }

Expand Down

0 comments on commit cc8ac50

Please sign in to comment.