From 2cebab406278fb35c5dc0521d6909f88d7edfd35 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sat, 14 Oct 2023 20:54:51 +0200 Subject: [PATCH] Use Array instead of ReadonlyArray MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I can’t find any reason to use `ReadonlyArray`. Looking at the git history, I can’t find anything interesting either. My best guess is that it’s a leftover from when the library was written in Flow and TypeScript was a second class citizen. --- README.md | 4 ++-- index.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 77e8145..153f683 100644 --- a/README.md +++ b/README.md @@ -298,7 +298,7 @@ Decodes a JSON string into a TypeScript `string`. ### stringUnion ```ts -function stringUnion]>( +function stringUnion]>( variants: T ): Decoder; ``` @@ -497,7 +497,7 @@ See also the [renaming union field example](examples/renaming-union-field.test.t ### tuple ```ts -function tuple>( +function tuple>( mapping: readonly [...{ [P in keyof T]: Decoder }] ): Decoder<[...T]>; ``` diff --git a/index.ts b/index.ts index b85a460..461e50e 100644 --- a/index.ts +++ b/index.ts @@ -37,7 +37,7 @@ export function string(value: unknown): string { return value; } -export function stringUnion]>( +export function stringUnion]>( variants: readonly [...T] ): Decoder { return function stringUnionDecoder(value: unknown): T[number] { @@ -234,7 +234,7 @@ export function fieldsUnion>>( >; } -export function tuple>( +export function tuple>( mapping: readonly [...{ [P in keyof T]: Decoder }] ): Decoder<[...T]> { return function tupleDecoder(value: unknown): [...T] {