-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Add Intl.ListFormat to es2021 lib #46907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It's ES2021 per the Finished Proposals list. |
Thanks for pointing that out, I've updated the issue accordingly. |
Is there a workaround for this? |
Personally, I used something like: 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[];
}
} |
Thanks for the help. That works great for making the linting errors go away, but (I'm using Deno) I still get |
The Deno REPL uses swc to transpile TypeScript without doing any type-checking, so that difference doesn't mean Deno or TypeScript comes with typings for |
Yes. I understood that. The types are missing, but the REPL cares not. But the actual code must be there or it wouldn't work at all, no? The VSCode linter picks up the above namespace declaration and the red squiggles go away, but clearly the bundler and test in Deno do not, as they fail the type check. |
@chasm I haven't much experience with it, but I found this in Deno's docs:
Maybe refering to the |
Excellent. I will check that out. Thanks. |
is this live? i cant find ListFormat after installing https://www.npmjs.com/package/@types/intl |
This is live, and that package is outdated and should not be required in any situation. Make sure your |
Suggestion
π Search Terms
Intl.ListFormat
Intl
ListFormat
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
Add
Intl.ListFormat
to es2021 lib types (as per Finished Proposals).Bringing this API to Typescript has been directly suggested before, but didn't follow the issue templates (#46866), and was also mentioned before (#45646 (comment), #29129 (comment)), but, as I couldn't find any specific active issue where the feature suggestion is being considered, I'm opening this issue.
π Motivating Example
Code that uses the Intl.ListFormat API should not fail type checking:
π» Use Cases
The text was updated successfully, but these errors were encountered: