Skip to content

Using class/style attribute on Vue components throws type error with Vue 2.7 #1500

@johannes-z

Description

@johannes-z

In my template I'm rendering a Vue component and specify the class and style attribute on the tag, like so:

<MyComponent class="my-class" style="font-weight: bold" data-value="test" />

I get a type error, saying:

Type '{ class: string; dataValue: any; "data-value": any; }' is not assignable to type 'IntrinsicAttributes & Readonly<Partial<{ selected: boolean; }> & Omit<{ selected: boolean; } & {}, "selected">>'.
  Property 'class' does not exist on type 'IntrinsicAttributes & Readonly<Partial<{ selected: boolean; }> & Omit<{ selected: boolean; } & {}, "selected">>'.ts(2322)

The component looks like this:

export default defineComponent({
  name: 'MyComponent',

  functional: true,

  props: {
    selected: { type: Boolean, default: false },
  },

  render () // omitted for brevity
})

The type checking should allow specifying class and style attributes.

I'm using Vue 2.7 ^2.7.0-beta.5

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