Skip to content

Commit 4413dd5

Browse files
committed
Move the Internationalization API to its own file and include it in ES6 typings
1 parent 19854a0 commit 4413dd5

3 files changed

Lines changed: 172 additions & 170 deletions

File tree

Jakefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ var harnessSources = [
9292

9393
var librarySourceMap = [
9494
{ target: "lib.core.d.ts", sources: ["core.d.ts"] },
95-
{ target: "lib.dom.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "dom.generated.d.ts"], },
96-
{ target: "lib.webworker.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "webworker.generated.d.ts"], },
95+
{ target: "lib.dom.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "intl.d.ts", "dom.generated.d.ts"], },
96+
{ target: "lib.webworker.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "intl.d.ts", "webworker.generated.d.ts"], },
9797
{ target: "lib.scriptHost.d.ts", sources: ["importcore.d.ts", "scriptHost.d.ts"], },
98-
{ target: "lib.d.ts", sources: ["core.d.ts", "extensions.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], },
99-
{ target: "lib.es6.d.ts", sources: ["core.d.ts", "es6.d.ts"]},
98+
{ target: "lib.d.ts", sources: ["core.d.ts", "extensions.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], },
99+
{ target: "lib.es6.d.ts", sources: ["core.d.ts", "es6.d.ts", "intl.d.ts"]},
100100
];
101101

102102
var libraryTargets = librarySourceMap.map(function (f) {

src/lib/extensions.d.ts

Lines changed: 0 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -655,169 +655,3 @@ interface Set<T> {
655655
declare var Set: {
656656
new <T>(): Set<T>;
657657
}
658-
659-
declare module Intl {
660-
661-
interface CollatorOptions {
662-
usage?: string;
663-
localeMatcher?: string;
664-
numeric?: boolean;
665-
caseFirst?: string;
666-
sensitivity?: string;
667-
ignorePunctuation?: boolean;
668-
}
669-
670-
interface ResolvedCollatorOptions {
671-
locale: string;
672-
usage: string;
673-
sensitivity: string;
674-
ignorePunctuation: boolean;
675-
collation: string;
676-
caseFirst: string;
677-
numeric: boolean;
678-
}
679-
680-
interface Collator {
681-
compare(x: string, y: string): number;
682-
resolvedOptions(): ResolvedCollatorOptions;
683-
}
684-
var Collator: {
685-
new (locales?: string[], options?: CollatorOptions): Collator;
686-
new (locale?: string, options?: CollatorOptions): Collator;
687-
(locales?: string[], options?: CollatorOptions): Collator;
688-
(locale?: string, options?: CollatorOptions): Collator;
689-
supportedLocalesOf(locales: string[], options?: CollatorOptions): string[];
690-
supportedLocalesOf(locale: string, options?: CollatorOptions): string[];
691-
}
692-
693-
interface NumberFormatOptions {
694-
localeMatcher?: string;
695-
style?: string;
696-
currency?: string;
697-
currencyDisplay?: string;
698-
useGrouping?: boolean;
699-
}
700-
701-
interface ResolvedNumberFormatOptions {
702-
locale: string;
703-
numberingSystem: string;
704-
style: string;
705-
currency?: string;
706-
currencyDisplay?: string;
707-
minimumintegerDigits: number;
708-
minimumFractionDigits: number;
709-
maximumFractionDigits: number;
710-
minimumSignificantDigits?: number;
711-
maximumSignificantDigits?: number;
712-
useGrouping: boolean;
713-
}
714-
715-
interface NumberFormat {
716-
format(value: number): string;
717-
resolvedOptions(): ResolvedNumberFormatOptions;
718-
}
719-
var NumberFormat: {
720-
new (locales?: string[], options?: NumberFormatOptions): Collator;
721-
new (locale?: string, options?: NumberFormatOptions): Collator;
722-
(locales?: string[], options?: NumberFormatOptions): Collator;
723-
(locale?: string, options?: NumberFormatOptions): Collator;
724-
supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[];
725-
supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[];
726-
}
727-
728-
interface DateTimeFormatOptions {
729-
localeMatcher?: string;
730-
weekday?: string;
731-
era?: string;
732-
year?: string;
733-
month?: string;
734-
day?: string;
735-
hour?: string;
736-
minute?: string;
737-
second?: string;
738-
timeZoneName?: string;
739-
formatMatcher?: string;
740-
hour12: boolean;
741-
}
742-
743-
interface ResolvedDateTimeFormatOptions {
744-
locale: string;
745-
calendar: string;
746-
numberingSystem: string;
747-
timeZone: string;
748-
hour12?: boolean;
749-
weekday?: string;
750-
era?: string;
751-
year?: string;
752-
month?: string;
753-
day?: string;
754-
hour?: string;
755-
minute?: string;
756-
second?: string;
757-
timeZoneName?: string;
758-
}
759-
760-
interface DateTimeFormat {
761-
format(date: number): string;
762-
resolvedOptions(): ResolvedDateTimeFormatOptions;
763-
}
764-
var DateTimeFormat: {
765-
new (locales?: string[], options?: DateTimeFormatOptions): Collator;
766-
new (locale?: string, options?: DateTimeFormatOptions): Collator;
767-
(locales?: string[], options?: DateTimeFormatOptions): Collator;
768-
(locale?: string, options?: DateTimeFormatOptions): Collator;
769-
supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[];
770-
supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[];
771-
}
772-
}
773-
774-
interface String {
775-
/**
776-
* Determines whether two strings are equivalent in the current locale.
777-
* @param that String to compare to target string
778-
* @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details.
779-
* @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details.
780-
*/
781-
localeCompare(that: string, locales: string[], options?: Intl.CollatorOptions): number;
782-
783-
/**
784-
* Determines whether two strings are equivalent in the current locale.
785-
* @param that String to compare to target string
786-
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details.
787-
* @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details.
788-
*/
789-
localeCompare(that: string, locale: string, options?: Intl.CollatorOptions): number;
790-
}
791-
792-
interface Number {
793-
/**
794-
* Converts a number to a string by using the current or specified locale.
795-
* @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
796-
* @param options An object that contains one or more properties that specify comparison options.
797-
*/
798-
toLocaleString(locales?: string[], options?: Intl.NumberFormatOptions): string;
799-
800-
/**
801-
* Converts a number to a string by using the current or specified locale.
802-
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
803-
* @param options An object that contains one or more properties that specify comparison options.
804-
*/
805-
toLocaleString(locale?: string, options?: Intl.NumberFormatOptions): string;
806-
}
807-
808-
interface Date {
809-
/**
810-
* Converts a date to a string by using the current or specified locale.
811-
* @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
812-
* @param options An object that contains one or more properties that specify comparison options.
813-
*/
814-
toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string;
815-
816-
/**
817-
* Converts a date to a string by using the current or specified locale.
818-
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
819-
* @param options An object that contains one or more properties that specify comparison options.
820-
*/
821-
toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
822-
}
823-

src/lib/intl.d.ts

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
/////////////////////////////
2+
/// ECMAScript Internationalization API
3+
/////////////////////////////
4+
5+
declare module Intl {
6+
interface CollatorOptions {
7+
usage?: string;
8+
localeMatcher?: string;
9+
numeric?: boolean;
10+
caseFirst?: string;
11+
sensitivity?: string;
12+
ignorePunctuation?: boolean;
13+
}
14+
15+
interface ResolvedCollatorOptions {
16+
locale: string;
17+
usage: string;
18+
sensitivity: string;
19+
ignorePunctuation: boolean;
20+
collation: string;
21+
caseFirst: string;
22+
numeric: boolean;
23+
}
24+
25+
interface Collator {
26+
compare(x: string, y: string): number;
27+
resolvedOptions(): ResolvedCollatorOptions;
28+
}
29+
var Collator: {
30+
new (locales?: string[], options?: CollatorOptions): Collator;
31+
new (locale?: string, options?: CollatorOptions): Collator;
32+
(locales?: string[], options?: CollatorOptions): Collator;
33+
(locale?: string, options?: CollatorOptions): Collator;
34+
supportedLocalesOf(locales: string[], options?: CollatorOptions): string[];
35+
supportedLocalesOf(locale: string, options?: CollatorOptions): string[];
36+
}
37+
38+
interface NumberFormatOptions {
39+
localeMatcher?: string;
40+
style?: string;
41+
currency?: string;
42+
currencyDisplay?: string;
43+
useGrouping?: boolean;
44+
}
45+
46+
interface ResolvedNumberFormatOptions {
47+
locale: string;
48+
numberingSystem: string;
49+
style: string;
50+
currency?: string;
51+
currencyDisplay?: string;
52+
minimumintegerDigits: number;
53+
minimumFractionDigits: number;
54+
maximumFractionDigits: number;
55+
minimumSignificantDigits?: number;
56+
maximumSignificantDigits?: number;
57+
useGrouping: boolean;
58+
}
59+
60+
interface NumberFormat {
61+
format(value: number): string;
62+
resolvedOptions(): ResolvedNumberFormatOptions;
63+
}
64+
var NumberFormat: {
65+
new (locales?: string[], options?: NumberFormatOptions): Collator;
66+
new (locale?: string, options?: NumberFormatOptions): Collator;
67+
(locales?: string[], options?: NumberFormatOptions): Collator;
68+
(locale?: string, options?: NumberFormatOptions): Collator;
69+
supportedLocalesOf(locales: string[], options?: NumberFormatOptions): string[];
70+
supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[];
71+
}
72+
73+
interface DateTimeFormatOptions {
74+
localeMatcher?: string;
75+
weekday?: string;
76+
era?: string;
77+
year?: string;
78+
month?: string;
79+
day?: string;
80+
hour?: string;
81+
minute?: string;
82+
second?: string;
83+
timeZoneName?: string;
84+
formatMatcher?: string;
85+
hour12: boolean;
86+
}
87+
88+
interface ResolvedDateTimeFormatOptions {
89+
locale: string;
90+
calendar: string;
91+
numberingSystem: string;
92+
timeZone: string;
93+
hour12?: boolean;
94+
weekday?: string;
95+
era?: string;
96+
year?: string;
97+
month?: string;
98+
day?: string;
99+
hour?: string;
100+
minute?: string;
101+
second?: string;
102+
timeZoneName?: string;
103+
}
104+
105+
interface DateTimeFormat {
106+
format(date: number): string;
107+
resolvedOptions(): ResolvedDateTimeFormatOptions;
108+
}
109+
var DateTimeFormat: {
110+
new (locales?: string[], options?: DateTimeFormatOptions): Collator;
111+
new (locale?: string, options?: DateTimeFormatOptions): Collator;
112+
(locales?: string[], options?: DateTimeFormatOptions): Collator;
113+
(locale?: string, options?: DateTimeFormatOptions): Collator;
114+
supportedLocalesOf(locales: string[], options?: DateTimeFormatOptions): string[];
115+
supportedLocalesOf(locale: string, options?: DateTimeFormatOptions): string[];
116+
}
117+
}
118+
119+
interface String {
120+
/**
121+
* Determines whether two strings are equivalent in the current locale.
122+
* @param that String to compare to target string
123+
* @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details.
124+
* @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details.
125+
*/
126+
localeCompare(that: string, locales: string[], options?: Intl.CollatorOptions): number;
127+
128+
/**
129+
* Determines whether two strings are equivalent in the current locale.
130+
* @param that String to compare to target string
131+
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details.
132+
* @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details.
133+
*/
134+
localeCompare(that: string, locale: string, options?: Intl.CollatorOptions): number;
135+
}
136+
137+
interface Number {
138+
/**
139+
* Converts a number to a string by using the current or specified locale.
140+
* @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
141+
* @param options An object that contains one or more properties that specify comparison options.
142+
*/
143+
toLocaleString(locales?: string[], options?: Intl.NumberFormatOptions): string;
144+
145+
/**
146+
* Converts a number to a string by using the current or specified locale.
147+
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
148+
* @param options An object that contains one or more properties that specify comparison options.
149+
*/
150+
toLocaleString(locale?: string, options?: Intl.NumberFormatOptions): string;
151+
}
152+
153+
interface Date {
154+
/**
155+
* Converts a date to a string by using the current or specified locale.
156+
* @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
157+
* @param options An object that contains one or more properties that specify comparison options.
158+
*/
159+
toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string;
160+
161+
/**
162+
* Converts a date to a string by using the current or specified locale.
163+
* @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used.
164+
* @param options An object that contains one or more properties that specify comparison options.
165+
*/
166+
toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string;
167+
}
168+

0 commit comments

Comments
 (0)