-
Notifications
You must be signed in to change notification settings - Fork 429
Open
Labels
Description
propertyNames is included in the "not expressible in TS" list, but at least for the case with enum instead of pattern, this is not true. Consider the following example:
{
"type": "object",
"title": "workingHours",
"definitions": {
"weekdays": {"type": "string", "enum": ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]}
},
"additionalProperties": {"type": "number"},
"propertyNames": {"$ref": "#/definitions/weekdays"}
}
could well be expressed in TS as
enum weekdays {
monday = "monday",
tuesday = "tuesday",
wednesday = "wednesday",
thursday = "thursday",
friday = "friday",
saturday = "saturday",
sunday = "sunday"
}
type workingHours = {[k in weekdays]: number};
The example also shows what would be the purpose of this instead of specifying the properties literally: weekdays does not have to be repeated all the time when there are more types making use of its keys.
andreww2012 and JosNun