Skip to content

Commit

Permalink
Use Array instead of ReadonlyArray
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lydell committed Oct 14, 2023
1 parent eb2a48a commit 2cebab4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ Decodes a JSON string into a TypeScript `string`.
### stringUnion

```ts
function stringUnion<T extends [string, ...ReadonlyArray<string>]>(
function stringUnion<T extends [string, ...Array<string>]>(
variants: T
): Decoder<T[number]>;
```
Expand Down Expand Up @@ -497,7 +497,7 @@ See also the [renaming union field example](examples/renaming-union-field.test.t
### tuple
```ts
function tuple<T extends ReadonlyArray<unknown>>(
function tuple<T extends Array<unknown>>(
mapping: readonly [...{ [P in keyof T]: Decoder<T[P]> }]
): Decoder<[...T]>;
```
Expand Down
4 changes: 2 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function string(value: unknown): string {
return value;
}

export function stringUnion<T extends [string, ...ReadonlyArray<string>]>(
export function stringUnion<T extends [string, ...Array<string>]>(
variants: readonly [...T]
): Decoder<T[number]> {
return function stringUnionDecoder(value: unknown): T[number] {
Expand Down Expand Up @@ -234,7 +234,7 @@ export function fieldsUnion<T extends Record<string, Decoder<unknown>>>(
>;
}

export function tuple<T extends ReadonlyArray<unknown>>(
export function tuple<T extends Array<unknown>>(
mapping: readonly [...{ [P in keyof T]: Decoder<T[P]> }]
): Decoder<[...T]> {
return function tupleDecoder(value: unknown): [...T] {
Expand Down

0 comments on commit 2cebab4

Please sign in to comment.