-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Add d.ts for Intl.RelativeTimeFormat #36084
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
Conversation
👋 hi, you submitted this just as we were preparing for a release, and we get really slow on 3rd party PRs during that period. We're now on 3.9 for master and I think this looks good. You're welcome to ping me on any I've only got one request, can you consider adding some JSDoc comments to the user facing parts of the API? |
👋@orta Could you give me the rules for these JSDoc comments or link to example of it in the current code base? |
There aren't any rules - it's just that you see these in your editor, and it's good to provide context for users. For example, I took some of the spec text and applied the useful bits of text to the prominent user-facing parts of the API interface RelativeTimeFormat {
/**
* Formats a value and unit according to the locale and formatting options of this Intl.RelativeTimeFormat object.
*
* While this method automatically provides the correct plural forms, the grammatical form is otherwise as neutral as possible. It is the caller's responsibility to handle cut-off logic such as deciding between displaying "in 7 days" or "in 1 week". This API does not support relative dates involving compound units. e.g "in 5 days and 4 hours".
*/
format(
value: number,
unit: RelativeTimeFormatUnit,
): string;
/**
* A version of the format method which it returns an array of objects which represent "parts" of the object, separating the formatted number into its constituent parts and separating it from other surrounding text.
*/
formatToParts(
value: number,
unit: RelativeTimeFormatUnit,
): RelativeTimeFormatPart[];
resolvedOptions(): ResolvedRelativeTimeFormatOptions;
} |
This PR hasn't seen any activity for quite a while, so I'm going to close it to keep the number of open PRs manageable. Feel free to open a fresh PR or continue the discussion here. |
Sure.
|
These look great! |
# Conflicts: # src/testRunner/unittests/config/commandLineParsing.ts Conflicts were resolved
Done. |
Nope, this is good to go! Thanks |
Whoa, I just checked why |
* upstream/master: Make new error an error, not message fix(38299): use string literals as keys to creating rest result (microsoft#38600) Intersection check for empty object type shouldn't cause circularities (microsoft#38673) fix(38682): use stable typescript version (microsoft#38683) Add d.ts for Intl.RelativeTimeFormat (microsoft#36084) fix(38295): handle duplicate object literal keys which contain '+' and '-' tokens make last para of Actomics.notify optional. Fix some JSDoc factory function return types. fix order and tests move to invocationErrorDetails replace the original not-callable error Add _0_is_declared_here pointing to accessor declaration Better error message for accidental calls to get-accessors
What's the ETA for this being in the published typescript npm package? |
@kwasimensah Should be 4.0. See #38510 for details. |
@sandersn any news on the ETA for having this published? Just checked latest version and it's still not there. |
@Licen-it const timeFormatter = new Intl.RelativeTimeFormat(['en', 'fr', 'es', 'it', 'pt'], { numeric: 'always' }); |
Thanks...didn't think about changing the target in tsconfig. Thanks |
Intl.RelativeTimeFormat proposal was moved to stage 4 and included into ecma402 finished proposals
Fixes part of #29129