Hint on `Type` for type of type (e.g. 'typescript', 'flow')
bennypowers opened this issue · 2 comments
coptic: Any interest in improving the controls? For example, size here has three options, so a radio is a little nicer than having to type in something IMO. If there’s 3+ it could default to a select maybe?
bennyp: This could maybe be automated from the type field in a custom elements manifest, however, we'd have to assume the type text is typescript in order to parse the union, where the manifest scema makes no such assumption
coptic: Ya that’s what I was playing around with. That’s a good point though not assuming TS. FWIW, stencils doc schema and generator is nice in that it does parse any union into a values array.
tl;dr: tools can't know for certain what kind of string the type text is. If we added a hint (per file, or per type), they could parse the type to do things like generate radio buttons for demos
per type:
{
"schemaVersion": "1.0.0",
"readme": "",
"modules": [
{
"kind": "javascript-module",
"path": "my-element.js",
"declarations": [
{
"kind": "class",
"name": "MyElement",
"members": [
{
"kind": "field",
"name": "type",
"type": {
"text": "'number'|'string'|'boolean'",
"kind": "typescript"
}
}
]
}
]
}
]
}
per file
{
"schemaVersion": "1.0.0",
"readme": "",
"modules": [
{
"kind": "javascript-module",
"path": "my-element.js",
"types": "typescript",
"declarations": [
{
"kind": "class",
"name": "MyElement",
"members": [
{
"kind": "field",
"name": "type",
"type": {
"text": "'number'|'string'|'boolean'",
}
}
]
}
]
}
]
}
I think #51 means nearly the same