Skip to content

Conversation

mcous
Copy link
Collaborator

@mcous mcous commented Nov 18, 2024

When using @testing-library/[email protected] with Svelte 4, wrapping render can cause spurious @typescript-eslint/no-unsafe-argument errors. I suspect this is due to some sort of bug in eslint-plugin-svelte, but I have not yet produced a minimal reproduction.

import type { ComponentProps } from 'svelte';
import { render } from '@testing-library/svelte';

import Subject from '../app.svelte';

const renderSubject = (props: ComponentProps<Subject>) => {
  return render(Subject, props);
};
error  Unsafe argument of type `any` assigned to a parameter of type `SvelteComponentOptions<SvelteComponent<Record<string, any>, Record<string, any>, Record<string, any>>> | undefined`  @typescript-eslint/no-unsafe-argument

In the meantime, this PR

  • Adjusts the types so that ESLint does not get mad
  • Adds a failing test case to the types suite

@mcous mcous merged commit acbddfd into main Nov 18, 2024
29 checks passed
@mcous mcous deleted the fix/legacy-types-eslint branch November 18, 2024 21:55
Copy link

🎉 This PR is included in version 5.2.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant