@@ -970,15 +970,13 @@ definition of "resolved value".
970
970
971
971
## Introducing type names
972
972
973
- It's useful to be able to refer to two types:
973
+ It's useful to be able to refer to three types:
974
974
975
- * ` MessageValue ` : The "resolved value" type; see [ PR 728] ( https://github.com/unicode-org/message-format-wg/pull/728 ) .
976
- * ` ValueType ` : This type encompasses strings, numbers, date/time values,
975
+ * ` InputType ` : This type encompasses strings, numbers, date/time values,
977
976
all other possible implementation-specific types that input variables can be
978
- assigned to,
979
- and all possible implementation-specific types that custom and built-in
980
- functions can construct.
981
- Conceptually it's the union of an "input type" and a "formatted value".
977
+ assigned to. The details are implementation-specific.
978
+ * ` MessageValue ` : The "resolved value" type; see [ PR 728] ( https://github.com/unicode-org/message-format-wg/pull/728 ) .
979
+ * ` ValueType ` : This type is the union of an ` InputType ` and a ` MessageValue ` .
982
980
983
981
It's tagged with a string tag so functions can do type checks.
984
982
@@ -1017,8 +1015,10 @@ that functions can operate on.
1017
1015
The most ambitious solution is to specify
1018
1016
a type system for MessageFormat functions.
1019
1017
1020
- ` ValueType ` is the most general type
1018
+ In this solution, ` ValueType ` is not what is defined above,
1019
+ but instead is the most general type
1021
1020
in a system of user-defined types.
1021
+ (The internal definitions are omitted.)
1022
1022
Using the function registry,
1023
1023
each custom function could declare its own argument type
1024
1024
and result type.
@@ -1077,6 +1077,15 @@ impractical.
1077
1077
In the preservation model,
1078
1078
functions "pipeline" the input through multiple calls.
1079
1079
1080
+ The ` ValueType ` definition is different:
1081
+
1082
+ ``` ts
1083
+ interface ValueType {
1084
+ type(): string
1085
+ value(): InputType | MessageValue
1086
+ }
1087
+ ```
1088
+
1080
1089
The resolved value interface would include both "input"
1081
1090
and "output" methods:
1082
1091
@@ -1086,7 +1095,7 @@ interface MessageValue {
1086
1095
formatToX(): X // where X is an implementation-defined type
1087
1096
getInput(): ValueType
1088
1097
getOutput(): ValueType
1089
- properties(): { [key : string ]: MessageValue }
1098
+ properties(): { [key : string ]: ValueType }
1090
1099
selectKeys(keys : string []): string []
1091
1100
}
1092
1101
```
@@ -1100,7 +1109,7 @@ choose which options to pass through into the resulting
1100
1109
Instead of using ` unknown ` as the result type of ` getValue() ` ,
1101
1110
we use ` ValueType ` , mentioned previously.
1102
1111
Instead of using ` unknown ` as the value type for the
1103
- ` properties() ` object, we use ` MessageValue ` ,
1112
+ ` properties() ` object, we use ` ValueType ` ,
1104
1113
since options can also be full ` MessageValue ` s with their own options.
1105
1114
1106
1115
Without a mechanism for type signatures,
@@ -1137,8 +1146,8 @@ number : Number -> FormattedNumber
1137
1146
date : Date -> FormattedDate
1138
1147
```
1139
1148
1140
- The resolved value type would be the same as
1141
- in the formatted value model.
1149
+ The ` MessageValue ` type would be defined the same way
1150
+ as in the formatted value model.
1142
1151
1143
1152
The difference is that built-in functions
1144
1153
would not accept a "formatted result"
0 commit comments