2021-12-09 17:12:21 -05:00
/ * ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Copyright ( c ) Microsoft Corporation . All rights reserved .
Licensed under the Apache License , Version 2.0 ( the "License" ) ; you may not use
this file except in compliance with the License . You may obtain a copy of the
License at http : //www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN * AS IS * BASIS , WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND , EITHER EXPRESS OR IMPLIED , INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE , FITNESS FOR A PARTICULAR PURPOSE ,
MERCHANTABLITY OR NON - INFRINGEMENT .
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
/// <reference no-default-lib="true"/>
declare namespace Intl {
2022-09-19 17:00:01 -04:00
interface DateTimeFormatPartTypesRegistry {
fractionalSecond : any
}
2021-12-09 17:12:21 -05:00
interface DateTimeFormatOptions {
formatMatcher ? : "basic" | "best fit" | "best fit" | undefined ;
dateStyle ? : "full" | "long" | "medium" | "short" | undefined ;
timeStyle ? : "full" | "long" | "medium" | "short" | undefined ;
dayPeriod ? : "narrow" | "short" | "long" | undefined ;
2022-09-19 17:00:01 -04:00
fractionalSecondDigits? : 1 | 2 | 3 | undefined ;
}
interface DateTimeRangeFormatPart extends DateTimeFormatPart {
source : "startRange" | "endRange" | "shared"
2021-12-09 17:12:21 -05:00
}
2022-05-31 20:19:18 -04:00
interface DateTimeFormat {
formatRange ( startDate : Date | number | bigint , endDate : Date | number | bigint ) : string ;
2022-09-19 17:00:01 -04:00
formatRangeToParts ( startDate : Date | number | bigint , endDate : Date | number | bigint ) : DateTimeRangeFormatPart [ ] ;
2022-05-31 20:19:18 -04:00
}
2021-12-09 17:12:21 -05:00
interface ResolvedDateTimeFormatOptions {
formatMatcher ? : "basic" | "best fit" | "best fit" ;
dateStyle ? : "full" | "long" | "medium" | "short" ;
timeStyle ? : "full" | "long" | "medium" | "short" ;
hourCycle ? : "h11" | "h12" | "h23" | "h24" ;
dayPeriod ? : "narrow" | "short" | "long" ;
2022-09-19 17:00:01 -04:00
fractionalSecondDigits? : 1 | 2 | 3 ;
2021-12-09 17:12:21 -05:00
}
2022-01-17 00:50:10 -05:00
/ * *
* The locale matching algorithm to use .
*
2022-05-31 20:19:18 -04:00
* [ MDN ] ( https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#parameters).
2022-01-17 00:50:10 -05:00
* /
type ListFormatLocaleMatcher = "lookup" | "best fit" ;
2022-03-01 15:44:43 -05:00
/ * *
* The format of output message .
*
* [ MDN ] ( https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#parameters).
* /
2022-01-17 00:50:10 -05:00
type ListFormatType = "conjunction" | "disjunction" | "unit" ;
2022-03-01 15:44:43 -05:00
/ * *
* The length of the formatted message .
*
* [ MDN ] ( https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#parameters).
* /
2022-01-17 00:50:10 -05:00
type ListFormatStyle = "long" | "short" | "narrow" ;
2022-03-01 15:44:43 -05:00
/ * *
* An object with some or all properties of the ` Intl.ListFormat ` constructor ` options ` parameter .
*
* [ MDN ] ( https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#parameters).
* /
2022-01-17 00:50:10 -05:00
interface ListFormatOptions {
/** The locale matching algorithm to use. For information about this option, see [Intl page](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation). */
2022-05-31 20:19:18 -04:00
localeMatcher? : ListFormatLocaleMatcher | undefined ;
2022-01-17 00:50:10 -05:00
/** The format of output message. */
2022-05-31 20:19:18 -04:00
type ? : ListFormatType | undefined ;
2022-01-17 00:50:10 -05:00
/** The length of the internationalized message. */
2022-05-31 20:19:18 -04:00
style? : ListFormatStyle | undefined ;
2022-01-17 00:50:10 -05:00
}
2022-03-01 15:44:43 -05:00
2023-03-21 11:46:40 -04:00
interface ResolvedListFormatOptions {
locale : string ;
style : ListFormatStyle ;
type : ListFormatType ;
}
2022-01-17 00:50:10 -05:00
interface ListFormat {
/ * *
* Returns a string with a language - specific representation of the list .
*
* @param list - An iterable object , such as an [ Array ] ( https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array).
*
* @throws ` TypeError ` if ` list ` includes something other than the possible values .
*
* @returns { string } A language - specific formatted string representing the elements of the list .
*
* [ MDN ] ( https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/format).
* /
format ( list : Iterable < string > ) : string ;
/ * *
* Returns an Array of objects representing the different components that can be used to format a list of values in a locale - aware fashion .
*
* @param list - An iterable object , such as an [ Array ] ( https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array), to be formatted according to a locale.
*
* @throws ` TypeError ` if ` list ` includes something other than the possible values .
*
* @returns { { type : "element" | "literal" , value : string ; } [ ] } An Array of components which contains the formatted parts from the list .
*
* [ MDN ] ( https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/formatToParts).
* /
formatToParts ( list : Iterable < string > ) : { type : "element" | "literal" , value : string ; } [ ] ;
2023-03-21 11:46:40 -04:00
/ * *
* Returns a new object with properties reflecting the locale and style
* formatting options computed during the construction of the current
* ` Intl.ListFormat ` object .
*
* [ MDN ] ( https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/resolvedOptions).
* /
resolvedOptions ( ) : ResolvedListFormatOptions ;
2022-01-17 00:50:10 -05:00
}
const ListFormat : {
prototype : ListFormat ;
/ * *
* Creates [ Intl . ListFormat ] ( https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat) objects that
* enable language - sensitive list formatting .
*
* @param locales - A string with a [ BCP 47 language tag ] ( http : //tools.ietf.org/html/rfc5646), or an array of such strings.
* For the general form and interpretation of the ` locales ` argument ,
* see the [ ` Intl ` page ] ( https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
*
* @param options - An [ object ] ( https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat#parameters)
* with some or all options of ` ListFormatOptions ` .
*
* @returns [ Intl . ListFormatOptions ] ( https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat) object.
*
* [ MDN ] ( https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat).
* /
new ( locales? : BCP47LanguageTag | BCP47LanguageTag [ ] , options? : ListFormatOptions ) : ListFormat ;
/ * *
* Returns an array containing those of the provided locales that are
* supported in list formatting without having to fall back to the runtime ' s default locale .
*
* @param locales - A string with a [ BCP 47 language tag ] ( http : //tools.ietf.org/html/rfc5646), or an array of such strings.
* For the general form and interpretation of the ` locales ` argument ,
* see the [ ` Intl ` page ] ( https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation).
*
* @param options - An [ object ] ( https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/supportedLocalesOf#parameters).
* with some or all possible options .
*
* @returns An array of strings representing a subset of the given locale tags that are supported in list
* formatting without having to fall back to the runtime ' s default locale .
*
* [ MDN ] ( https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/supportedLocalesOf).
* /
supportedLocalesOf ( locales : BCP47LanguageTag | BCP47LanguageTag [ ] , options? : Pick < ListFormatOptions , " localeMatcher " > ) : BCP47LanguageTag [ ] ;
} ;
2022-05-31 20:19:18 -04:00
}