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
(searched all issues, the wiki, the code, google, and stackoverflow)
Code
constplurals=newIntl.PluralRules();// error: Property 'PluralRules' does not exist on type 'typeof Intl'.
Gist:
Intl.PluralRules is at Stage 4 and is supported by most browsers. In addition, there is a TC39 polyfill that exists for older browsers. I'd expect this now to exist in the DOM type definitions.
Expected behavior:Intl.PluralRules to be defined.
Actual behavior:Intl.PluralRules isn't defined anywhere. (I actually even took it one further and ripgrepped the entire repository for PluralRules and there were 0 matches.)
Mohamed Hegazy (@mhegazy) Looking at the example you linked to... I'm not sure how that file is even being included in the main lib.d.ts? I tried adding a slew of different configurations to my tsconfig (different targets, adding all of the es2017 libs, etc) and I still could not get formatToParts to ever show up.
Is this confirmed to be working correctly? What am I doing wrong here? Any tips are greatly appreciated.
Thanks for the info. That still only half-solves my question. Again, I've configured my tsconfig in every way imaginable and I still cannot get functionality from es2017.intl.d.ts to work right now in TypeScript (namely, the formatToParts method).
So my worry is that if that's someway malformatted or configured incorrectly, basing my PR on that implementation will lead to a malformatted or misconfigured implementation of PluralRules.
Thanks for the info. That's extremely helpful. Let's put a pin in this for now. I'll try and sort out what's going on on my machine and get back to this tomorrow at some point.
I still think the formatToParts method is not typed properly because your example works only when you declare d as type DateTimeFormat. It does not work, however, when it is type Intl.DateTimeFormat.
// does not workdeclarevard: Intl.DateTimeFormat;d.formatToParts();// Property 'formatToParts' does not exist on type 'DateTimeFormat'.
I think if formatToParts was typed similarly to how my implementation above, this issue will resolve.
Can you confirm this?
I tried in the playground, locally on my machine at home, and on codesandbox.com and all three locations I'm able to repro the issue.
.... full stop ....
With that in mind, what about just creating a lib.es2018.intl.d.ts file and literally dropping in the code snippet that I pasted in above? Would that work?
Second. If my suspicion is correct, should I start a new thread for the formatToParts issue?
Thanks for your patience. I greatly appreciate your hospitality.
So the declarations in es2017.intl.d.ts are completely wrong. there is no global type DateTimeFormat, there is only Intl.DateTimeFormat. so this files needs fixing as well. we need to wrap the file in declare namespace Intl { ... } declaration. thanks for pointing this one out.
Activity
mhegazy commentedon Apr 25, 2018
PRs welcomed. I think we can add that to
lib.es2018.intl.d.ts. see https://github.com/Microsoft/TypeScript/blob/master/src/lib/es2017.intl.d.ts for example.dsifford commentedon Apr 25, 2018
For those who need this right now:
Mohamed Hegazy (@mhegazy) Thanks for the info! I'll take a look either later tonight or tomorrow and give it a shot 👍
dsifford commentedon Apr 26, 2018
Mohamed Hegazy (@mhegazy) Looking at the example you linked to... I'm not sure how that file is even being included in the main
lib.d.ts? I tried adding a slew of different configurations to my tsconfig (different targets, adding all of thees2017libs, etc) and I still could not getformatToPartsto ever show up.Is this confirmed to be working correctly? What am I doing wrong here? Any tips are greatly appreciated.
mhegazy commentedon Apr 26, 2018
The final file is built using a
Jake/Gulptasks. here is a link https://github.com/Microsoft/TypeScript/blob/master/Jakefile.js#L120dsifford commentedon Apr 26, 2018
Thanks for the info. That still only half-solves my question. Again, I've configured my tsconfig in every way imaginable and I still cannot get functionality from
es2017.intl.d.tsto work right now in TypeScript (namely, theformatToPartsmethod).So my worry is that if that's someway malformatted or configured incorrectly, basing my PR on that implementation will lead to a malformatted or misconfigured implementation of
PluralRules.mhegazy commentedon Apr 26, 2018
tsc --lib es2017,es2017.intldsifford commentedon Apr 26, 2018
Mohamed Hegazy (@mhegazy) Did you try that?
Here's the output for me (latest TypeScript version):
From the schema currently listed at http://json.schemastore.org/tsconfig:
There is no mention of
es2017.intl.mhegazy commentedon Apr 26, 2018
dsifford commentedon Apr 27, 2018
hmmmm... The plot thickens.
Thanks for the info. That's extremely helpful. Let's put a pin in this for now. I'll try and sort out what's going on on my machine and get back to this tomorrow at some point.
Thanks again for all your help. 🙏
dsifford commentedon Apr 29, 2018
Alright Mohamed Hegazy (@mhegazy) so I investigated it further...
I still think the
formatToPartsmethod is not typed properly because your example works only when you declaredas typeDateTimeFormat. It does not work, however, when it is typeIntl.DateTimeFormat.I think if
formatToPartswas typed similarly to how my implementation above, this issue will resolve.Can you confirm this?
I tried in the playground, locally on my machine at home, and on codesandbox.com and all three locations I'm able to repro the issue.
.... full stop ....
With that in mind, what about just creating a
lib.es2018.intl.d.tsfile and literally dropping in the code snippet that I pasted in above? Would that work?Second. If my suspicion is correct, should I start a new thread for the
formatToPartsissue?Thanks for your patience. I greatly appreciate your hospitality.
mhegazy commentedon Apr 29, 2018
We need a new file, and we need it wired in the build like the lib.es217.intl.d.ts. And also in the commandline parser.
mhegazy commentedon Apr 29, 2018
I will need to check the spec for the formattoparts question and get back to you.
dsifford commentedon Apr 29, 2018
Ok sounds great. I'll hold off until you're able to confirm.
mhegazy commentedon Apr 30, 2018
So the declarations in
es2017.intl.d.tsare completely wrong. there is no global typeDateTimeFormat, there is onlyIntl.DateTimeFormat. so this files needs fixing as well. we need to wrap the file indeclare namespace Intl { ... }declaration. thanks for pointing this one out.dsifford commentedon Apr 30, 2018
Ok phew! Glad to hear I wasn't completely mistaken.
I'd be happy to attempt to tackle both of these. Would you prefer them in the same PR or separate?
mhegazy commentedon Apr 30, 2018
either is fine. up to you.
add lib.es2018.intl + fix lib.es2017.intl