-
Notifications
You must be signed in to change notification settings - Fork 25
Description
Currently the type def for the type object has only text
, references
, and sources
as available data.
Given that text
is meant to be type definition's text as is, there could be more detail added (and more features provided from analysis tools like cem/analyzer) if the type object is changd/expanded to something like:
export interface Type {
name?: string;
definition?: string;
values?: string[]
references?: TypeReference[];
source?: SourceReference;
}
Consider a case like this:
export type MyCustomType = 'valueA' | 'valueB';
@property() myProp: MyCustomType = 'valueA';
// cem.json
{
...
{
kind: field,
type: {
name: 'MyCustomType',
definition: `'valueA' | 'valueB'`,
values: [ 'valueA', 'valueB']
}
}
...
}
All the type properties would be optional to support different kinds of type definitions where not all parts would be able to be determined.
export type MyCustomType = { someProp: string; someOtherProp: number};
@property() myProp: MyCustomType;
// cem.json
{
...
{
kind: field,
type: {
name: 'MyCustomType',
definition: `{ someProp: string; someOtherProp: number}`,
values: undefined
}
}
...
}
If analysis tools can "unwrap" the named type definition and get at the actual values, those could be provided in js structures in the cem.json and unlock a TON of potential for the cem.json to be used in lots of different documentation implementations. Getting a list of the type values from the type itself isnt that easy, but getting it from the cem.json
would be trivial, but the schema as is doesnt have a place to put such information if it could be retrieved.