Subscribe on changes!

defineComponent setup function sees "props" as type any in TS

avatar
May 20th 2022

Vue version

3.2.34

Link to minimal reproduction

https://codesandbox.io/s/quirky-dust-62izo9?file=/src/main.js

Steps to reproduce

Mouse over the "props.modelValue" and see that both "modelValue" and "props" are seen as type any by TypeScript.

What is expected?

In previous versions, TypeScript (and the IDE) would recognize props with the correct object structure.

What is actually happening?

After upgrading from 3.2.33 to 3.2.34 it always sees props as type any.

I tested this in VS Code and Visual Studio 2019 as well as simply trying to build my project. All three report the wrong types for the props parameter.

image

System Info

No response

Any additional comments?

I was upgrading to get this fix: https://github.com/vuejs/core/pull/5871. Since it has to do with props I thought maybe it broke the setup function as a by-product of the fix. But reverting that change in the vue code in my node_modules did not restore the type information on "props".

avatar
May 20th 2022

I can't reproduce this, but can you upgrade to 3.2.35 to see if the issues still exist?

avatar
May 20th 2022

@yyx990803 Yes, 3.2.35 does indeed fix the problem! Thanks for the quick response, really appreciate it!