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

Supporting non-primitives in generated types #33

Closed
modularcoder opened this issue Oct 16, 2021 · 2 comments
Closed

Supporting non-primitives in generated types #33

modularcoder opened this issue Oct 16, 2021 · 2 comments

Comments

@modularcoder
Copy link
Contributor

Hello again :)

I'm developing a component, and one thing I've noticed that props are converted to primitives.

So this
image

Outputs
image

So seems that property with an interface

 someObjectProp: {
      boolProp: boolean
      stringProp: 'one' | 'two' | 'three'
 }

Gets compiled to

someObjectProp: {
       type: ObjectConstructor;
       required: true;
};

Wondering if this can be improved or is this vue/compiler-sfc limitation?
Thanks

@qmhc
Copy link
Owner

qmhc commented Oct 17, 2021

I think this is same to #25.

@modularcoder
Copy link
Contributor Author

modularcoder commented Oct 17, 2021

Right, thanks. Posting the link to the workaround and closing this issue, thanks

Workaround: use JS style props declaration as mentioned here
#25 (comment)

A temporary workaround is rollback to js-props:

<script setup lang="ts">
import type { PropType } from 'vue'

type Props = {
  color: 'blue' | 'red' | 'purple'
}
defineProps({
  color: String as PropType<Props['color']>
})
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants