Skip to content

[Proposal] Extend the type object with more detailed informationΒ #88

@michaelwarren1106

Description

@michaelwarren1106

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions