-
Notifications
You must be signed in to change notification settings - Fork 25
Description
When documenting a field of a custom element, we definitely want to describe it's type. Before TypeScript came along we almost would have certainly would have use JSDoc-style type annotation syntax, but TypeScript's type syntax might be more commonly known by now though.
So we could use that in the descriptor, for example:
{
"members": {
"foo": {
"kind": "property",
"type": "Array<number|string>"
}
}
}
But at the limit you need to support many TS-specific, non-concrete entries like interfaces and type aliases so that you can use them in types. Does this mean we should leave types completely out of the format and up to .d.ts files? That would degrade the usefulness for documentation tools that don't process type declaration files. TS declaration files are also harder to parse than JSON, requiring the whole TypeScript compiler.
Another option is to include much of the type-related information parsed by Microsoft's API Extractor: https://github.com/microsoft/rushstack/tree/master/apps/api-extractor
Since this tool produces JSON, it would be relatively easy for custom-elements.json
generators to use it to parse TypeScript, then merge with it's own custom element specific parsed metadata.