Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
m-kutnik opened this issue Sep 11, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@m-kutnik
Copy link

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:

type ExtractSlots<C> = AllowNonFunctionSlots<
Partial<RemoveIndexSignature<ComponentSlots<C>>>
>

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:

  • @testing-library/vue version: 8.1.0
  • Vue version: 3.4.34
  • node version: 20.17.0
  • npm version: 10.8.2
@m-kutnik m-kutnik added the bug Something isn't working label Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant