Skip to content

Attribute inheritance in TSX #3496

@PurpleTape

Description

@PurpleTape

Hello! I encountered the following situation: for vue components that wrap native html elements, all properties not specified in props automatically fall into attrs and can be applied to a native html element. However, volar indicates a typescript error, since properties not specified in props are missing from the type.

The problem occurs in the following cases:

  1. When using native html attributes on a component
  2. When a component wraps another component (WrapperComponent -> RootComponent). In this case, attributes not specified in props of WrapperComponent are passed to the attrs of RootComponent

Thus, the attributes are passed as intended, but the IDE displays a type error

Example:

// example.tsx
import { defineComponent } from 'vue'

const VButton = defineComponent(
  () => {
    return () => <button type="button">My button</button>
  },
  {
    props: {
      something: String
    }
  }
)

const usage = () => <VButton something="ok value" onClick={alert()} />
изображение

Info:
TypeScript Vue Plugin (Volar) v1.8.8

How can I eliminate the display of such errors?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions