From 9aeae461fdf9265389cf3dfe4e428b037215ba5f Mon Sep 17 00:00:00 2001 From: Giulio Canti Date: Fri, 22 Mar 2024 11:00:42 +0100 Subject: [PATCH] =?UTF-8?q?Schema:=20remove=20the=20custom=20`Simplify`=20?= =?UTF-8?q?type=20that=20was=20previously=20introd=E2=80=A6=20(#2391)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/breezy-jobs-change.md | 5 +++++ packages/schema/src/Schema.ts | 29 +++++++++-------------------- 2 files changed, 14 insertions(+), 20 deletions(-) create mode 100644 .changeset/breezy-jobs-change.md diff --git a/.changeset/breezy-jobs-change.md b/.changeset/breezy-jobs-change.md new file mode 100644 index 0000000000..45796de206 --- /dev/null +++ b/.changeset/breezy-jobs-change.md @@ -0,0 +1,5 @@ +--- +"@effect/schema": patch +--- + +Removed the custom `Simplify` type that was previously introduced to address a bug in TypeScript 5.0 diff --git a/packages/schema/src/Schema.ts b/packages/schema/src/Schema.ts index 3c2a7afc94..9a8b599996 100644 --- a/packages/schema/src/Schema.ts +++ b/packages/schema/src/Schema.ts @@ -48,17 +48,6 @@ import * as pretty_ from "./Pretty.js" import type * as Serializable from "./Serializable.js" import * as TreeFormatter from "./TreeFormatter.js" -/** - * Required to fix a bug in TypeScript@5.0, dtslint fails with: - * TypeScript@5.0 expected type to be: - * { readonly [x: string]: number; } - * got: - * { [x: string]: number; } - * - * @since 1.0.0 - */ -export type Simplify = { readonly [K in keyof T]: T[K] } & {} - /** * @since 1.0.0 */ @@ -2023,8 +2012,8 @@ export interface TypeLiteral< Records extends IndexSignature.Records > extends Schema< - Simplify>, - Simplify>, + Types.Simplify>, + Types.Simplify>, | Struct.Context | IndexSignature.Context > @@ -2032,7 +2021,7 @@ export interface TypeLiteral< readonly fields: { readonly [K in keyof Fields]: Fields[K] } readonly records: Readonly annotations( - annotations: Annotations.Schema>> + annotations: Annotations.Schema>> ): TypeLiteral } @@ -2043,8 +2032,8 @@ class TypeLiteralImpl< Fields extends Struct.Fields, const Records extends IndexSignature.Records > extends SchemaImpl< - Simplify>, - Simplify>, + Types.Simplify>, + Types.Simplify>, | Struct.Context | IndexSignature.Context > implements TypeLiteral { @@ -2136,7 +2125,7 @@ class TypeLiteralImpl< this.records = [...records] as Records } annotations( - annotations: Annotations.Schema>> + annotations: Annotations.Schema>> ): TypeLiteral { return new TypeLiteralImpl(this.fields, this.records, AST.annotations(this.ast, toASTAnnotations(annotations))) } @@ -2147,7 +2136,7 @@ class TypeLiteralImpl< * @since 1.0.0 */ export interface Struct extends TypeLiteral { - annotations(annotations: Annotations.Schema>>): Struct + annotations(annotations: Annotations.Schema>>): Struct } /** @@ -2174,7 +2163,7 @@ export interface $Record extends Typ readonly key: K readonly value: V annotations( - annotations: Annotations.Schema>> + annotations: Annotations.Schema>> ): $Record } @@ -2185,7 +2174,7 @@ class $RecordImpl extends TypeLitera constructor(readonly key: K, readonly value: V, ast?: AST.AST) { super({}, [{ key, value }], ast) } - annotations(annotations: Annotations.Schema>>) { + annotations(annotations: Annotations.Schema>>) { return new $RecordImpl(this.key, this.value, AST.annotations(this.ast, toASTAnnotations(annotations))) } }