File tree Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Expand file tree Collapse file tree 2 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -22,22 +22,20 @@ class Person {
2222
2323// TODO(stasm): This is generic enough that it could be in impl/runtime.ts.
2424class ListValue < T > extends RuntimeValue < Array < T > > {
25- private opts : Record < string , string > ; // ListFormatOptions
25+ private opts : Intl . ListFormatOptions ;
2626
27- constructor ( value : Array < T > , opts : Record < string , string > = { } ) {
27+ constructor ( value : Array < T > , opts : Intl . ListFormatOptions = { } ) {
2828 super ( value ) ;
2929 this . opts = opts ;
3030 }
3131
3232 formatToString ( ctx : FormattingContext ) : string {
3333 // TODO(stasm): Cache ListFormat.
34- // @ts -ignore
3534 let lf = new Intl . ListFormat ( ctx . locale , this . opts ) ;
3635 return lf . format ( this . value ) ;
3736 }
3837
3938 * formatToParts ( ctx : FormattingContext ) : IterableIterator < FormattedPart > {
40- // @ts -ignore
4139 let lf = new Intl . ListFormat ( ctx . locale , this . opts ) ;
4240 yield * lf . formatToParts ( this . value ) ;
4341 }
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