$el is typed as any
Vue version
3
Link to minimal reproduction
Steps to reproduce
this.$el
has the any
type
What is expected?
this.$el
has the Node | undefined
type
What is actually happening?
this.$el
has the any
type
System Info
No response
Any additional comments?
$el is defined at runtime-core/src/componentPublicInstance.ts line 197
I think it's indeed any
. Or, to make it safer, unknown
. Vue 3 didn't require element to meet specified interface because implementation of node operations is specified outside of runtime-core
https://github.com/vuejs/core/blob/main/packages/runtime-dom/src/nodeOps.ts
The $el can be whatever you want if you are in other runtime.
I agree with @mmis1000 , I also think it should be any
. You must know that Vue supports custom renderers, which makes the content rendered by components not necessarily standard dom elements
Maybe adjust the documentation at https://vuejs.org/api/component-instance.html#el to reflect that?
It states that $el
is Node | undefined
.
Wondering if it is possible to left it as a blank interface and argument in runtime-dom
.
Like what express.js does
https://stackoverflow.com/questions/37377731/extend-express-request-object-using-typescript
In this way, if you don't have runtime-dom
installed. It is {}
. Or if you have, it will suddenly be Node