Skip to content
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

Missing ListFormat types? #13199

Closed
chasm opened this issue Dec 25, 2021 · 6 comments · Fixed by #13301
Closed

Missing ListFormat types? #13199

chasm opened this issue Dec 25, 2021 · 6 comments · Fixed by #13301
Labels
bug Something isn't working correctly help wanted community help requested tsc related to the TypeScript tsc compiler upstream Changes in upstream are required to solve these issues

Comments

@chasm
Copy link

chasm commented Dec 25, 2021

I can do this in the REPL and it works:

new Intl.ListFormat("en", {
    style: "long",
    type: "conjunction",
}).format(['red', 'green', 'blue']) // returns "red, green, and blue"

But if I put the same code in my Deno application, I get:

[ERROR]: Property 'ListFormat' does not exist on type 'typeof Intl'.

when I try to bundle it.

@kitsonk
Copy link
Contributor

kitsonk commented Dec 25, 2021

Can you provide a full reproduction and include the output of deno --version.

@kitsonk kitsonk added the needs info needs further information to be properly triaged label Dec 25, 2021
@chasm
Copy link
Author

chasm commented Dec 25, 2021

This is literally my entire code in a file called mod.ts:

const ListFormatter = new Intl.ListFormat("en", {
	style: "long",
	type: "conjunction",
});

console.log(ListFormatter.format(["apples", "pears", "peaches", "plums"]));

Here's what happens when I run it:

[listFormat] deno run ./mod.ts
Check file:///Users/chasm/Workspace/listFormat/mod.ts
error: TS2339 [ERROR]: Property 'ListFormat' does not exist on type 'typeof Intl'.
const ListFormatter = new Intl.ListFormat("en", {
                               ~~~~~~~~~~
    at file:///Users/chasm/Workspace/listFormat/mod.ts:1:32

Here is the output of deno --version:

[listFormat] deno --version
deno 1.17.1 (release, x86_64-apple-darwin)
v8 9.7.106.15
typescript 4.5.2

Here is what happens when I do the same thing in the REPL:

[listFormat] deno
Deno 1.17.1
exit using ctrl+d or close()
> const ListFormatter = new Intl.ListFormat("en", {
	style: "long",
	type: "conjunction",
});

console.log(ListFormatter.format(["apples", "pears", "peaches", "plums"]));
apples, pears, peaches, and plums
undefined
>

As the output is correct, clearly Intl.ListFormat does exist in Deno. The problem appears only when it is type checked.

Ideas? Is there a workaround?

@crowlKats
Copy link
Member

This is an issue with typescript itself: microsoft/TypeScript#46907

@crowlKats crowlKats removed the needs info needs further information to be properly triaged label Dec 25, 2021
@chasm
Copy link
Author

chasm commented Dec 25, 2021

Thanks. I'll check on it there.

@andreubotella
Copy link
Contributor

andreubotella commented Dec 25, 2021

We have added built-in APIs to the Typescript definition files when a version of Deno would ship with those APIs but Typescript didn't support them yet (see #11443, for example). The differences here is that Intl.ListFormat shipped a while ago (browser-compat-data lists it as shipping in Chrome 72) and apparently no one noticed until now, and that there isn't yet even a PR for adding the definitions in Typescript. But I don't see why we couldn't open a PR to Typescript and float the patch in Deno while it gets reviewed upstream.

@chasm
Copy link
Author

chasm commented Dec 26, 2021

That would be awesome...

@kitsonk kitsonk added bug Something isn't working correctly tsc related to the TypeScript tsc compiler upstream Changes in upstream are required to solve these issues help wanted community help requested labels Dec 26, 2021
andreubotella pushed a commit to andreubotella/deno that referenced this issue Jan 7, 2022
V8 has supported `Intl.ListFormat` since version 7.2, but TypeScript doesn't
have typings for it yet. This PR manually adds those typings, copying them from
mirosoft/TypeScript#47254.

Fixes denoland#13199.
andreubotella pushed a commit to andreubotella/deno that referenced this issue Jan 7, 2022
V8 has supported `Intl.ListFormat` since version 7.2, but TypeScript doesn't
have typings for it yet. This PR manually adds those typings, copying them from
microsoft/TypeScript#47254.

Fixes denoland#13199.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly help wanted community help requested tsc related to the TypeScript tsc compiler upstream Changes in upstream are required to solve these issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants