Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tobiasdiez opened this issue Aug 8, 2024 · 0 comments
Open

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

tobiasdiez opened this issue Aug 8, 2024 · 0 comments
Labels
status: help wanted Good idea, but the core developers will not work on it at the moment type: enhancement Improving upon an existing feature

Comments

@tobiasdiez
Copy link
Owner

tobiasdiez commented Aug 8, 2024

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:

@tobiasdiez tobiasdiez added type: enhancement Improving upon an existing feature status: help wanted Good idea, but the core developers will not work on it at the moment labels Aug 8, 2024
@tobiasdiez tobiasdiez changed the title Vue Language Plugin for type inference Vue Language Plugin for type inference of defineMeta and args Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted Good idea, but the core developers will not work on it at the moment type: enhancement Improving upon an existing feature
Projects
None yet
Development

No branches or pull requests

1 participant