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

defineProps options object loses properties when using generics #9546

Open
pikax opened this issue Nov 4, 2023 · 2 comments
Open

defineProps options object loses properties when using generics #9546

pikax opened this issue Nov 4, 2023 · 2 comments
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: types

Comments

@pikax
Copy link
Member

pikax commented Nov 4, 2023

Vue version

3.3.7 & 3.4.alpha

Link to minimal reproduction

https://play.vuejs.org/#eNqNUk1v2zAM/SuELt2Axj70MMBIi25DD9thLbYcdXFsxlVmUxolpxkC//fS8kfT9AO9UXyP5OOjDuqrc8muRZWppS/YuAAeQ+ugzqm61Cp4raBCQjaFPFdaXWkyjbMc4AB3bN3qv0PoYMO2gTPpdKapsOQDOAE9XEKJG0PYU/2ngyaAPIPb9RaLALmfWyxXV+eaenidQaQBBMm/we0J3VhQfKRAuD2D8V9rGMsMArcYk52m7nPfKQpO8ilYT0GhaZkO5shcda6G/RdN7pKttyTexfl6BMSyWZFWYkn/1uo+BOezNC1KkrISa7PjhDCk5Jr0WmgptxRMg4vSNtcXyUXyJS2ND8fpBH2zWLN98MjSRKtxrTgmleQOecFIJTLyR8eelB2PPoFejJ/8E1OCl7NvTHViSWEbZ2rkWxeMfItn1uR1bR9+xtx8jVhzj8XfV/Jbvx92umOMyo72DzlXGAb45s8v3Es8g40t23o8wxvgb/S2bnuNA+1bS6XIPuJFtT/ihQ1VK3+zD0h+WqoXOn3K8R7f31n9Sa64PbvYPQLEQTNC

Steps to reproduce

image
<script setup lang="ts" generic="T">
import { PropType } from 'vue'
const props = defineProps({
  a: Object as PropType<T>,

  b: {
    type: Object as PropType<T>
  },

  c: {
    type: Object as PropType<T>,
    required: true,
  }
})

props.a
props.b
props.c
</script>

What is expected?

The props to be declared correctly

What is actually happening?

Properties are been excluded from props, unless they are required 🤔

System Info

No response

Any additional comments?

No response

@pikax pikax added scope: types 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. labels Nov 4, 2023
@KUN1007
Copy link

KUN1007 commented Nov 6, 2023

You should add the type property to define the props object.

<script setup lang="ts" generic="T">
import { PropType } from 'vue'
const props = defineProps({
  a: {
    type: Object as PropType<T>,
  },
  b: {
    type: Object as PropType<T>,
  },

  c: {
    type: Object as PropType<T>,
    required: true,
  },
})

props.a
props.b
props.c
</script>

You can see: https://deepscan.io/docs/rules/vue-bad-prop-decl#:~:text=This%20rule%20applies%20when%20a,an%20object%20with%20validation%20requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: types
Projects
None yet
Development

No branches or pull requests

3 participants