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

attribute inheritance when strictTemplates enabled #4699

Closed
Doeke opened this issue Aug 16, 2024 · 4 comments · Fixed by #4103
Closed

attribute inheritance when strictTemplates enabled #4699

Doeke opened this issue Aug 16, 2024 · 4 comments · Fixed by #4103
Labels
bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first

Comments

@Doeke
Copy link

Doeke commented Aug 16, 2024

Vue - Official extension or vue-tsc version

2.0.21

VSCode version

1.92.2

Vue version

3.4.29

TypeScript version

5.4.0

System Info

System:
    OS: Linux 6.8 Ubuntu 24.04 LTS 24.04 LTS (Noble Numbat)
    CPU: (16) x64 AMD Ryzen 7 7840U w/ Radeon  780M Graphics
    Memory: 13.28 GB / 30.66 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 20.15.1 - ~/.nvm/versions/node/v20.15.1/bin/node
    npm: 10.8.2 - ~/.nvm/versions/node/v20.15.1/bin/npm
  Browsers:
    Chrome: 127.0.6533.119

Steps to reproduce

Enable strictTemplates: true and run type-check on vue templates that contain certain fallthrough attributes/events like id on a component:

<HelloWorld msg="You did it!" id="4" />

The other attributes that don't work are title and aria-* attributes.

Another problem is with the @click event listener on components that use defineModel (see repro link)

What is expected?

No typechecking errors are expected as attributes like id and aria-label should be treated as allowed fallthrough attributes.

What is actually happening?

Type check fails with errors (Object literal may only specify known properties):

src/App.vue:15:37 - error TS2353: Object literal may only specify known properties, and 'id' does not exist in type 'Partial<{}> & Omit<{ readonly msg?: string | undefined; } & VNodeProps & AllowedComponentProps & ComponentCustomProps & Readonly<...>, never>'.

15       <HelloWorld msg="You did it!" id="4" />

Link to minimal reproduction

https://github.com/Doeke/bug-stricttemplates

Any additional comments?

No response

@KazariEX
Copy link
Collaborator

Might be fixed by #4103

@Doeke
Copy link
Author

Doeke commented Aug 16, 2024

@KazariEX What about @click + defineModel case? Is that also the same issue with fallthrough attributes?

@KazariEX
Copy link
Collaborator

KazariEX commented Aug 16, 2024

@Doeke This is actually caused by the update event defined by defineModel. When there are no events on a component, its $emit will be inferred as any event function. Could you create a separate issue for this so that my PR can link it correctly?

@Doeke
Copy link
Author

Doeke commented Aug 16, 2024

@KazariEX

New issue for event listener errors: #4701

@KermanX KermanX changed the title Errors with strictTemplates enabled (id, title, aria-label, click) attribute inheritance when strictTemplates enabled Aug 17, 2024
@KermanX KermanX added bug Something isn't working and removed pending triage labels Aug 17, 2024
@johnsoncodehk johnsoncodehk added the good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first label Aug 25, 2024
johnsoncodehk added a commit to so1ve/language-tools that referenced this issue Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good reproduction ✨ This issue provides a good reproduction, we will be able to investigate it first
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants