@@ -980,15 +980,13 @@ definition of "resolved value".
980
980
981
981
## Introducing type names
982
982
983
- It's useful to be able to refer to two types:
983
+ It's useful to be able to refer to three types:
984
984
985
- * ` MessageValue ` : The "resolved value" type; see [ PR 728] ( https://github.com/unicode-org/message-format-wg/pull/728 ) .
986
- * ` ValueType ` : This type encompasses strings, numbers, date/time values,
985
+ * ` InputType ` : This type encompasses strings, numbers, date/time values,
987
986
all other possible implementation-specific types that input variables can be
988
- assigned to,
989
- and all possible implementation-specific types that custom and built-in
990
- functions can construct.
991
- Conceptually it's the union of an "input type" and a "formatted value".
987
+ assigned to. The details are implementation-specific.
988
+ * ` MessageValue ` : The "resolved value" type; see [ PR 728] ( https://github.com/unicode-org/message-format-wg/pull/728 ) .
989
+ * ` ValueType ` : This type is the union of an ` InputType ` and a ` MessageValue ` .
992
990
993
991
It's tagged with a string tag so functions can do type checks.
994
992
@@ -1027,8 +1025,10 @@ that functions can operate on.
1027
1025
The most ambitious solution is to specify
1028
1026
a type system for MessageFormat functions.
1029
1027
1030
- ` ValueType ` is the most general type
1028
+ In this solution, ` ValueType ` is not what is defined above,
1029
+ but instead is the most general type
1031
1030
in a system of user-defined types.
1031
+ (The internal definitions are omitted.)
1032
1032
Using the function registry,
1033
1033
each custom function could declare its own argument type
1034
1034
and result type.
@@ -1087,6 +1087,15 @@ impractical.
1087
1087
In the preservation model,
1088
1088
functions "pipeline" the input through multiple calls.
1089
1089
1090
+ The ` ValueType ` definition is different:
1091
+
1092
+ ``` ts
1093
+ interface ValueType {
1094
+ type(): string
1095
+ value(): InputType | MessageValue
1096
+ }
1097
+ ```
1098
+
1090
1099
The resolved value interface would include both "input"
1091
1100
and "output" methods:
1092
1101
@@ -1096,7 +1105,7 @@ interface MessageValue {
1096
1105
formatToX(): X // where X is an implementation-defined type
1097
1106
getInput(): ValueType
1098
1107
getOutput(): ValueType
1099
- properties(): { [key : string ]: MessageValue }
1108
+ properties(): { [key : string ]: ValueType }
1100
1109
selectKeys(keys : string []): string []
1101
1110
}
1102
1111
```
@@ -1110,7 +1119,7 @@ choose which options to pass through into the resulting
1110
1119
Instead of using ` unknown ` as the result type of ` getValue() ` ,
1111
1120
we use ` ValueType ` , mentioned previously.
1112
1121
Instead of using ` unknown ` as the value type for the
1113
- ` properties() ` object, we use ` MessageValue ` ,
1122
+ ` properties() ` object, we use ` ValueType ` ,
1114
1123
since options can also be full ` MessageValue ` s with their own options.
1115
1124
1116
1125
Without a mechanism for type signatures,
@@ -1147,8 +1156,8 @@ number : Number -> FormattedNumber
1147
1156
date : Date -> FormattedDate
1148
1157
```
1149
1158
1150
- The resolved value type would be the same as
1151
- in the formatted value model.
1159
+ The ` MessageValue ` type would be defined the same way
1160
+ as in the formatted value model.
1152
1161
1153
1162
The difference is that built-in functions
1154
1163
would not accept a "formatted result"
0 commit comments