From 84d331725bdf77514d6720dffe91a9316167eea0 Mon Sep 17 00:00:00 2001 From: Giulio Canti Date: Fri, 31 May 2024 08:04:30 +0200 Subject: [PATCH] DeepMutable: remove redundant branch (#2885) --- packages/effect/dtslint/Types.ts | 55 ++++++++++++++++++++++++++------ packages/effect/src/Types.ts | 1 - 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/packages/effect/dtslint/Types.ts b/packages/effect/dtslint/Types.ts index 6dc3fdb96a..7f67e26aa6 100644 --- a/packages/effect/dtslint/Types.ts +++ b/packages/effect/dtslint/Types.ts @@ -81,23 +81,60 @@ type TaggedValues = { readonly value: ReadonlyArray } -// $ExpectType [string, number, boolean, bigint] -hole<[Types.DeepMutable, Types.DeepMutable, Types.DeepMutable, Types.DeepMutable]>() - +// primitive types and literals +// $ExpectType [string, number, boolean, bigint, symbol, never, null, "a", 1, true] +hole< + [ + Types.DeepMutable, + Types.DeepMutable, + Types.DeepMutable, + Types.DeepMutable, + Types.DeepMutable, + Types.DeepMutable, + Types.DeepMutable, + Types.DeepMutable<"a">, + Types.DeepMutable<1>, + Types.DeepMutable + ] +>() + +// record // $ExpectType { [x: string]: number; } hole>() +// $ExpectType { [x: string]: number; } +hole>() -// $ExpectType Set<{ value: { _tag: string; value: number[]; }; }> -hole }>>>() - -// $ExpectType Map<{ _tag: string; value: string[]; }, Set<{ _tag: string; value: number[]; }>> -hole, ReadonlySet>>>>() - +// structs +// $ExpectType {} +hole>() // $ExpectType { _tag: string; value: { _tag: string; value: { _tag: string; value: boolean[]; }[]; }[]; }[] hole>>>>>() +// array +// $ExpectType [] +hole>() +// $ExpectType string[] +hole>>() +// $ExpectType string[] +hole>>() + +// tuples // $ExpectType [string, number, boolean] hole>() +// $ExpectType [string, number, boolean] +hole>() + +// ReadonlySet +// $ExpectType Set<{ value: { _tag: string; value: number[]; }; }> +hole }>>>() +// $ExpectType Set<{ value: { _tag: string; value: number[]; }; }> +hole }>>>() + +// ReadonlyMap +// $ExpectType Map<{ _tag: string; value: string[]; }, Set<{ _tag: string; value: number[]; }>> +hole, ReadonlySet>>>>() +// $ExpectType Map<{ _tag: string; value: string[]; }, Set<{ _tag: string; value: number[]; }>> +hole, ReadonlySet>>>>() // ------------------------------------------------------------------------------------- // MatchRecord diff --git a/packages/effect/src/Types.ts b/packages/effect/src/Types.ts index 47dd8ae7b4..592c9f93d6 100644 --- a/packages/effect/src/Types.ts +++ b/packages/effect/src/Types.ts @@ -187,7 +187,6 @@ export type Mutable = { */ export type DeepMutable = T extends ReadonlyMap ? Map, DeepMutable> : T extends ReadonlySet ? Set> - : T extends ReadonlyArray ? { -readonly [K in keyof T]: DeepMutable } : [keyof T] extends [never] ? T : { -readonly [K in keyof T]: DeepMutable }