Subscribe on changes!

SFC generics - cannot use generic prop as object key in template without `props`

avatar
Apr 24th 2023

Vue version

3.2.45

Link to minimal reproduction

https://github.com/cohlar/vue-rfc436/tree/prop_object_key_error

Steps to reproduce

  1. Open in IDE with volar enabled or run vue-tsc (tested with versions 1.0.9 to 1.4.3)
  2. TheWelcome component should show TS errors

What is expected?

Props defined with defineProps should be available in the template without the need to use const props = defineProps<...>() and props. before the prop name.

What is actually happening?

We must use const props = defineProps<...>() in the script and props. before the prop name in the template to get no error.

System Info

No response

Any additional comments?

This issue was initially raised in the volar repo and @johnsoncodehk proposed a "naive" solution.

avatar
Apr 25th 2023

FYI the fix proposed here doesn't pass the dts tests in core.