JetBrains / web-types

JSON standard for documenting web component libraries for IDEs, documentation generators and other tools
Apache License 2.0
285 stars 25 forks source link

Better support for union types #51

Closed MiniDigger closed 2 years ago

MiniDigger commented 2 years ago

Just found this project in hopes of improving auto completion for my lib, its looking not bad!

Sadly I use union types for many values and I am missing auto completion for those. e.g: I define my props using vue3's script setup and typescript:

const props = withDefaults(
  defineProps<{
    disabled?: boolean;
    size?: "small" | "medium" | "large";
    buttonType?: "primary" | "secondary" | "red" | "transparent";
    loading?: boolean;
    to?: string | RouteLocationRaw | object;
  }>(),
  {
    disabled: false,
    size: "small",
    buttonType: "primary",
    loading: false,
    to: undefined,
  }
);

the generator creates this attribute for "buttonType":

            {
              "name": "buttonType",
              "required": false,
              "value": {
                "kind": "expression",
                "type": "union"
              },
              "default": "\"primary\""
            },

loosing all the context of my union :/

piotrtomiak commented 2 years ago

@MiniDigger Do you mean vue-docgen-web-types? It uses vue-docgen-api package to analyze the source code. Please file an issue in vue-styleguidist repository. The problematic code is if (TS_TYPE_NAME_MAP[t.type]). The TS_TYPE_NAME_MAP contains special rendering for union instead of processing each item and displaying them.