File tree 2 files changed +27
-4
lines changed 2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -22,22 +22,20 @@ class Person {
22
22
23
23
// TODO(stasm): This is generic enough that it could be in impl/runtime.ts.
24
24
class ListValue < T > extends RuntimeValue < Array < T > > {
25
- private opts : Record < string , string > ; // ListFormatOptions
25
+ private opts : Intl . ListFormatOptions ;
26
26
27
- constructor ( value : Array < T > , opts : Record < string , string > = { } ) {
27
+ constructor ( value : Array < T > , opts : Intl . ListFormatOptions = { } ) {
28
28
super ( value ) ;
29
29
this . opts = opts ;
30
30
}
31
31
32
32
formatToString ( ctx : FormattingContext ) : string {
33
33
// TODO(stasm): Cache ListFormat.
34
- // @ts -ignore
35
34
let lf = new Intl . ListFormat ( ctx . locale , this . opts ) ;
36
35
return lf . format ( this . value ) ;
37
36
}
38
37
39
38
* formatToParts ( ctx : FormattingContext ) : IterableIterator < FormattedPart > {
40
- // @ts -ignore
41
39
let lf = new Intl . ListFormat ( ctx . locale , this . opts ) ;
42
40
yield * lf . formatToParts ( this . value ) ;
43
41
}
Original file line number Diff line number Diff line change
1
+ declare namespace Intl {
2
+ interface ListFormatOptions {
3
+ // I added `string` to avoid having to validate the exact values of options.
4
+ localeMatcher ?: string | "best fit" | "lookup" ;
5
+ type ?: string | "conjunction" | "disjunction | unit" ;
6
+ style ?: string | "long" | "short" | "narrow" ;
7
+ }
8
+
9
+ type ListFormatPartTypes = "literal" | "element" ;
10
+
11
+ interface ListFormatPart {
12
+ type : ListFormatPartTypes ;
13
+ value : string ;
14
+ }
15
+
16
+ interface ListFormat {
17
+ format ( value ?: Array < unknown > ) : string ;
18
+ formatToParts ( value ?: Array < unknown > ) : ListFormatPart [ ] ;
19
+ }
20
+
21
+ var ListFormat : {
22
+ new ( locales ?: string | string [ ] , options ?: ListFormatOptions ) : ListFormat ;
23
+ ( locales ?: string | string [ ] , options ?: ListFormatOptions ) : ListFormat ;
24
+ } ;
25
+ }
You can’t perform that action at this time.
0 commit comments