You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Thanks for the help. That works great for making the linting errors go away, but (I'm using Deno) I still get [ERROR]: Property 'ListFormat' does not exist on type 'typeof Intl'. when I try to bundle it or run tests. And yet it works fine in the Deno REPL, so I know that it does exist.... I guess I don't understand Deno/TS enough to see what's going on.
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 Intl.ListFormat.
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.
Another option is to use a configuration file that is configured to include the type definitions, by supplying a "types" value to the "compilerOptions". For example:
This is live, and that package is outdated and should not be required in any situation. Make sure your target is es2021 or higher, and if that still doesn't work, please open a new issue rather than commenting on an old issue. Thanks.
Activity
saschanaz commentedon Dec 4, 2021
It's ES2021 per the Finished Proposals list.
[-]Add Intl.ListFormat to es2020 lib[/-][+]Add Intl.ListFormat to es2021 lib[/+]vhfmag commentedon Dec 12, 2021
Thanks for pointing that out, I've updated the issue accordingly.
chasm commentedon Dec 25, 2021
Is there a workaround for this?
vhfmag commentedon Dec 25, 2021
Personally, I used something like:
chasm commentedon Dec 25, 2021
Thanks for the help. That works great for making the linting errors go away, but (I'm using Deno) I still get
[ERROR]: Property 'ListFormat' does not exist on type 'typeof Intl'.when I try to bundle it or run tests. And yet it works fine in the Deno REPL, so I know that it does exist.... I guess I don't understand Deno/TS enough to see what's going on.andreubotella commentedon Dec 25, 2021
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
Intl.ListFormat.chasm commentedon Dec 26, 2021
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.
vhfmag commentedon Dec 26, 2021
Charles F. Munat (@chasm) I haven't much experience with it, but I found this in Deno's docs:
Maybe refering to the
.d.tsfile would make the bundler aware of it?chasm commentedon Dec 26, 2021
Excellent. I will check that out. Thanks.
AndreMantas commentedon May 28, 2022
is this live? i cant find ListFormat after installing https://www.npmjs.com/package/@types/intl
saschanaz commentedon May 29, 2022
This is live, and that package is outdated and should not be required in any situation. Make sure your
targetises2021or higher, and if that still doesn't work, please open a new issue rather than commenting on an old issue. Thanks.