Skip to content

Commit

Permalink
chore: types
Browse files Browse the repository at this point in the history
Signed-off-by: Logan McAnsh <logan@mcan.sh>
  • Loading branch information
mcansh committed Mar 7, 2023
1 parent a06bf65 commit 14ba1e0
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions packages/remix-dev/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 14ba1e0

Please sign in to comment.