testing-library / vue-testing-library

🦎 Simple and complete Vue.js testing utilities that encourage good testing practices.
http://testing-library.com/vue
MIT License
1.09k stars 109 forks source link

`RemoveIndexSignature` causes TS Errors with Mapped Types in Vue slots #321

Open m-kutnik opened 2 months ago

m-kutnik commented 2 months ago

Describe the bug Hi, I'm unable to test my Generic component that uses mapped types to create the slots dynamically. When I attempt to test the component using Testing Library, the mapped types are removed from the slots type, causing TypeScript errors likeObject literal may only specify known properties, and X does not exist in type Y (screen 3)

After reviewing the type definitions, I noticed that ExtractSlots uses RemoveIndexSignature which appears to remove the mapped types from the component's slots. Why is that the case?

It's worth noting that Vue Test Utils does not remove the mapped types from the slots' annotation (screen 4).

Type definition: https://github.com/testing-library/vue-testing-library/blob/d46ed8f757e77fe85b369847c21d394bb9706066/types/index.d.ts#L54-L56

To Reproduce Steps to reproduce the behavior:

I haven't prepared a reproduction case, but I can create one if needed

Expected behavior

Mapped types should be preserved in the slots' type

Screenshots

  1. Slots definition image
  2. Mapped type for header slots image
  3. Error output image
  4. Slots type using Vue Test Utils image

Related information: