Skip to content

Vue Language Plugin for type inference of defineMeta and args #119

@tobiasdiez

Description

@tobiasdiez

At the moment, one needs to pass the meta object to the Story component to get the correct types for args etc. The idea would be to add a language plugin that does this automatically. So the following code would work and provide proper types for args

<script setup lang="ts">
import Button from "./b-button.vue";

defineMeta({
  component: Button,
  args: {
    label: 'Click',
    variant: 'primary',
  }
})

</script>

<template>
<Story v-slot="{ args }">
   <Button :label="args.label" /> <!-- the value here is "Click"-->
</Story>
<!-- Args can be overridden locally by passing them to the Story component   -->
<Story v-slot="{ args }" :args="{ label: 'Custom Label'}">
   <Button :label="args.label"/> <!-- the value here is "Custom Label"-->
</Story>
</template>

References:

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: help wantedGood idea, but the core developers will not work on it at the momenttype: enhancementImproving upon an existing feature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions