vuejs / vue-class-component

ES / TypeScript decorator for class-style Vue components.
MIT License
5.81k stars 431 forks source link

Add support for static properties #614

Closed NikhilVerma closed 1 year ago

NikhilVerma commented 2 years ago

Typescript decorators have a known issue that they can't mutate their target types. See extended discussion here: https://github.com/microsoft/TypeScript/issues/4881

What this means is that if we use the @Component decorator syntax, we have no way to add any statically extractable components list if we pass any. This prevents advanced usages of Typescript components.

However if we allow the consumers to define a static components property, tools like Volar - https://github.com/johnsoncodehk/volar (which also includes vue-tsc) can extract the child-component types.

Another benefit to this is that we don't need to introduce a breaking change, as if someone defined a static property in their class components right now vue-class-component will not extract them anyway.