@@ -16,14 +16,14 @@ export type FluentFunction = (
16
16
* them, which can then be used in the `toString` method together with a proper
17
17
* `Intl` formatter.
18
18
*/
19
- export class FluentType < T > {
19
+ export abstract class FluentType < T > {
20
20
/** The wrapped native value. */
21
21
public value : T ;
22
22
23
23
/**
24
24
* Create a `FluentType` instance.
25
25
*
26
- * @param value - JavaScript value to wrap.
26
+ * @param value The JavaScript value to wrap.
27
27
*/
28
28
constructor ( value : T ) {
29
29
this . value = value ;
@@ -42,12 +42,8 @@ export class FluentType<T> {
42
42
* Formatted values are suitable for use outside of the `FluentBundle`.
43
43
* This method can use `Intl` formatters available through the `scope`
44
44
* argument.
45
- *
46
- * @abstract
47
45
*/
48
- toString ( scope : Scope ) : string {
49
- throw new Error ( "Subclasses of FluentType must implement toString." ) ;
50
- }
46
+ abstract toString ( scope : Scope ) : string ;
51
47
}
52
48
53
49
/**
@@ -56,7 +52,7 @@ export class FluentType<T> {
56
52
export class FluentNone extends FluentType < string > {
57
53
/**
58
54
* Create an instance of `FluentNone` with an optional fallback value.
59
- * @param value - The fallback value of this `FluentNone`.
55
+ * @param value The fallback value of this `FluentNone`.
60
56
*/
61
57
constructor ( value = "???" ) {
62
58
super ( value ) ;
@@ -72,14 +68,21 @@ export class FluentNone extends FluentType<string> {
72
68
73
69
/**
74
70
* A `FluentType` representing a number.
71
+ *
72
+ * A `FluentNumber` instance stores the number value of the number it
73
+ * represents. It may also store an option bag of options which will be passed
74
+ * to `Intl.NumerFormat` when the `FluentNumber` is formatted to a string.
75
75
*/
76
76
export class FluentNumber extends FluentType < number > {
77
- /** Options passed to Intl.NumberFormat. */
77
+ /** Options passed to ` Intl.NumberFormat` . */
78
78
public opts : Intl . NumberFormatOptions ;
79
79
80
80
/**
81
81
* Create an instance of `FluentNumber` with options to the
82
82
* `Intl.NumberFormat` constructor.
83
+ *
84
+ * @param value The number value of this `FluentNumber`.
85
+ * @param opts Options which will be passed to `Intl.NumberFormat`.
83
86
*/
84
87
constructor ( value : number , opts : Intl . NumberFormatOptions = { } ) {
85
88
super ( value ) ;
@@ -102,16 +105,22 @@ export class FluentNumber extends FluentType<number> {
102
105
103
106
/**
104
107
* A `FluentType` representing a date and time.
108
+ *
109
+ * A `FluentDateTime` instance stores the number value of the date it
110
+ * represents, as a numerical timestamp in milliseconds. It may also store an
111
+ * option bag of options which will be passed to `Intl.DateTimeFormat` when the
112
+ * `FluentDateTime` is formatted to a string.
105
113
*/
106
114
export class FluentDateTime extends FluentType < number > {
107
- /** Options passed to Intl.DateTimeFormat. */
115
+ /** Options passed to ` Intl.DateTimeFormat` . */
108
116
public opts : Intl . DateTimeFormatOptions ;
109
117
110
118
/**
111
119
* Create an instance of `FluentDateTime` with options to the
112
120
* `Intl.DateTimeFormat` constructor.
113
- * @param value - timestamp in milliseconds
114
- * @param opts
121
+ *
122
+ * @param value The number value of this `FluentDateTime`, in milliseconds.
123
+ * @param opts Options which will be passed to `Intl.DateTimeFormat`.
115
124
*/
116
125
constructor ( value : number , opts : Intl . DateTimeFormatOptions = { } ) {
117
126
super ( value ) ;
0 commit comments