Skip to content

Web components cannot be typechecked in templates with the defineCustomElement function #2314

@adrienZ

Description

@adrienZ

the guide https://vuejs.org/guide/extras/web-components.html#building-custom-elements-with-vue may not be detailed enought for library authors.

creating a custom elements defineCustomElement will not be enought to allow type checking on vue template

I managed to do it by extending vue module types (as a believe this whats Nuxt does)

import Counter from './src/components/counter.ce.vue'

declare module 'vue' {
  export interface GlobalComponents {
    'web-counter': typeof Counter,
    'WebCounter': typeof Counter,
  }
}

source code
MicrosoftTeams-image (1)

Should we add this in the guide ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions