From 14ba1e0fc049d5576b76c017ecd42210c1fd2ab0 Mon Sep 17 00:00:00 2001 From: Logan McAnsh Date: Tue, 7 Mar 2023 11:19:59 -0500 Subject: [PATCH] chore: types Signed-off-by: Logan McAnsh --- packages/remix-dev/config.ts | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/packages/remix-dev/config.ts b/packages/remix-dev/config.ts index 77a3e5db01e..8510e170a2e 100644 --- a/packages/remix-dev/config.ts +++ b/packages/remix-dev/config.ts @@ -761,15 +761,38 @@ const resolveServerBuildPath = ( return path.resolve(rootDirectory, serverBuildPath); }; -// @ts-expect-error available in node 12+ -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat#browser_compatibility +// adds types for `Intl.ListFormat` to the global namespace +// we could also update our `tsconfig.json` to include `lib: ["es2021"]` +declare namespace Intl { + type ListType = "conjunction" | "disjunction"; + + interface ListFormatOptions { + localeMatcher?: "lookup" | "best fit"; + type?: ListType; + style?: "long" | "short" | "narrow"; + } + + interface ListFormatPart { + type: "element" | "literal"; + value: string; + } + + class ListFormat { + constructor(locales?: string | string[], options?: ListFormatOptions); + format(values: any[]): string; + formatToParts(values: any[]): ListFormatPart[]; + supportedLocalesOf( + locales: string | string[], + options?: ListFormatOptions + ): string[]; + } +} + let conjunctionListFormat = new Intl.ListFormat("en", { style: "long", type: "conjunction", }); -// @ts-expect-error available in node 12+ -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat#browser_compatibility let disjunctionListFormat = new Intl.ListFormat("en", { style: "long", type: "disjunction",