Subscribe on changes!

Inherit attributes with generic components causes type error

avatar
May 19th 2023

Vue version

3.3.4

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-nwkbil?file=package.json,src%2Fcomponents%2FListGeneric.vue,src%2FApp.vue,src%2Fcomponents%2FList.vue

Steps to reproduce

  1. Open a new Terminal after successful setup of dependencies
  2. Type and run npm run typecheck into the terminal
  3. See an error in App.vue file

What is expected?

There is no error occurred

What is actually happening?

TS2345: Argument of type '{ dataCy: string; "data-cy": string; modelValue: "modelValue"; "onUpdate:modelValue": any; }' is not assignable to parameter of type '{ modelValue: "modelValue"; sameModel?: string | undefined; } & VNodeProps & AllowedComponentProps & ComponentCustomProps'.
  Object literal may only specify known properties, and 'dataCy' does not exist in type '{ modelValue: "modelValue"; sameModel?: string | undefined; } & VNodeProps & AllowedComponentProps & ComponentCustomProps'.

System Info

No response

Any additional comments?

No response

avatar
May 19th 2023

Looks like its because of empty ComponentCustomProps interface

export interface ComponentCustomProps {
}
avatar
Jul 15th 2023

bump - need this please

avatar
Aug 12th 2023

I've found a workaround, but it may have side effects

const props = defineProps<{
  // allow other attributes
  [attrs: string]: any

  // props...
}>()
avatar
Oct 18th 2023

any news?

avatar
Nov 7th 2023

No longer reproduced on vue-tsc@1.8.22