From c6f491ec4682aaef3a05d385e21c41a1227159f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20Sj=C3=B6green?= Date: Tue, 3 Sep 2024 10:50:59 +0200 Subject: [PATCH] fix: Parenthesize inner type of array --- deno.json | 2 +- mod.ts | 2 +- types/urlsearchparams.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deno.json b/deno.json index 00f461a..da73860 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@denosaurs/typefetch", - "version": "0.0.11", + "version": "0.0.12", "exports": { ".": "./main.ts" }, diff --git a/mod.ts b/mod.ts index 27e3a9f..f52942b 100644 --- a/mod.ts +++ b/mod.ts @@ -149,7 +149,7 @@ export function toSchemaType( } case "array": { const items = toSchemaType(document, schema.items); - if (items !== undefined) return `${items}[]`; + if (items !== undefined) return `(${items})[]`; return "unknown[]"; } case "null": diff --git a/types/urlsearchparams.ts b/types/urlsearchparams.ts index 8da0605..6e9e5a0 100644 --- a/types/urlsearchparams.ts +++ b/types/urlsearchparams.ts @@ -64,7 +64,7 @@ type MayInclude = R | { [K i * @example MustInclude<"a" | "b"> = ["a", "b"] | ["b", "a"] * @example MustInclude<"a" | "b" | "c"> = ["a", "b", "c"] | ["a", "c", "b"] | ["b", "a", "c"] | ["b", "c", "a"] | ["c", "a", "b"] | ["c", "b", "a"] */ -type MustInclude = { [K in T]: Exclude extends never ? [K] : [K, ...MustInclude>] }[T]; +type MustInclude = { [K in T]: [Exclude] extends [never] ? [K] : [K, ...MustInclude>] }[T]; /** * Extracts all required search params as a union of `URLSearchParamsKeyValue`