Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$el is typed as any #7915

Open
DellCliff opened this issue Mar 18, 2023 · 4 comments
Open

$el is typed as any #7915

DellCliff opened this issue Mar 18, 2023 · 4 comments

Comments

@DellCliff
Copy link

Vue version

3

Link to minimal reproduction

https://sfc.vuejs.org/#eNpVUcFOwzAM/RUTIXWTWCquWzeE4MAfcMlltO7WKXGixNmQqv47TjcmOLXP7/n52RnVawj6nFGtVZPaOASGhJzDztDggo8MI0TsYYI+egeVSCtDhlpPicGlA2wLv6g+0FoPnz7a7qFaGmrqq50YCWB0we4ZBQE0x+fdOM7N09TUgubqQCEznFfOd2i3RglvlFBNfe9WT+qaauX2QZ+SJ8k9lm5zI5JRa5grpSZpCzbqyBzSuq5T35ZtT0n7eKjlT8dMPDjUmNzqK/pLwijGRhWLydAkI8uJOMmk+0U67AfCNy+YkPjfdTZlYfyelaLbZzt//+oXc8BWYGbsfuN2vs2usMv7AhzlLSIBH4ekH9G+aH8hjO83pYwqMol5zbrcqOkHn+mgyA==

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

himself65 added a commit to himself65/vue-next that referenced this issue Mar 21, 2023
@mmis1000
Copy link
Contributor

mmis1000 commented Mar 21, 2023

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.

@baiwusanyu-c
Copy link
Member

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

@DellCliff
Copy link
Author

Maybe adjust the documentation at https://vuejs.org/api/component-instance.html#el to reflect that?
It states that $el is Node | undefined.

@mmis1000
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants