Subscribe on changes!

Props type on component instance is weird when passing an empty object to the `props` field

avatar
Jul 21st 2023

Vue version

3.3.4

Link to minimal reproduction

https://play.vuejs.org/#eNp9UU1PAjEQ/SuTxgRMcDlwQzBRgwkelKg362FdZnFxd6ZpZ/nIZv+7bQlgCOHQpn3vzeubaaPujUlWNaqhGglWpkwF70b9w1H1lLiMKS8WydIxeV2jCUCrjCtTlGhfjRRMTqshRCZwaVny+jliYmvs7fHsB7PfM/jSbQKm1cyiQ7tCrQ6cpHaBsqMn7y+48ecDWfG8Lr36AvmGjss6ZNzJHmqa+9j/dDHttDJspaDFh5tsBMntmwpBg7KNeq38sB4vtH6MO0gGsU5T66eYJuL88Ir4DDQwx7yg6MSEJNBCbrna+Wt1q62msPzoncATM4xPS7pNFImxbJxP0Pag34fRDfi/ky1EGPh7iZkEYXt9YjoN2xgI18G/e6RlaxBmsXwM4cJ5FH92rqJp50u1fw6OvtI=

Steps to reproduce

Open the production link, goto a.ts, and hover on Props. You'll see it's type is weird.

image

What is expected?

It should be an empty object

What is actually happening?

It includes many array methods.

System Info

Irrelevant - we can reproduce it easily in vue playground and it's a type issue

Any additional comments?

https://github.com/vuejs/language-tools/issues/3430

avatar
Jul 27th 2023

On first glance, it looks like the array types may be coming from the string[] part of this union

https://github.com/vuejs/core/blob/3be4e3cbe34b394096210897c1be8deeb6d748d8/packages/runtime-core/src/componentProps.ts#L44-L46