JetBrains / web-types

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

Add support for Vue 3.4's defineModel() macro #80

Closed tofi86 closed 3 months ago

tofi86 commented 3 months ago

Vue 3.4 moved defineModel() to stable: https://blog.vuejs.org/posts/vue-3-4#definemodel-is-now-stable

So I was trying to replace the following code

defineProps<{
    street: string | null;
    city: string | null;
    otherProp: number;
  }>()

const emit = defineEmits<{
  (e: 'update:street', value: string | null): void;
  (e: 'update:city', value: string | null): void;
}>();

const localStreet = computed({
  get() {
    return props.street;
  },
  set(newValue: string | null): void {
    emit('update:street', newValue);
  },
});

const localCity = computed({
  get() {
    return props.city;
  },
  set(newValue: string | null): void {
    emit('update:city', newValue);
  },
});

with

defineProps<{
    otherProp: number;
  }>();

const street = defineModel<string | null>('street', { required: true });
const city = defineModel<string | null>('city', { required: true });

But then, the vue-docgen-web-types macro will remove

from the generated web-types.json.

piotrtomiak commented 3 months ago

@tofi86 - vue-docgen-web-types fully depends on https://www.npmjs.com/package/vue-docgen-api to generate the output. It turns out this is not yet supported - https://github.com/vue-styleguidist/vue-styleguidist/issues/1627