sveltejs / eslint-plugin-svelte

ESLint plugin for Svelte using AST
https://sveltejs.github.io/eslint-plugin-svelte/
MIT License
276 stars 30 forks source link

Component type is inferred as any #717

Closed Stadly closed 3 months ago

Stadly commented 3 months ago

Before You File a Bug Report Please Confirm You Have Done The Following...

What version of ESLint are you using?

8.57.0

What version of eslint-plugin-svelte are you using?

2.35.1

What did you do?

Configuration ```js module.exports = { extends: ['plugin:@typescript-eslint/recommended-type-checked'], overrides: [ { files: ['*.svelte'], parser: 'svelte-eslint-parser', parserOptions: { parser: '@typescript-eslint/parser', project: true, tsconfigRootDir: __dirname, }, }, ], parser: '@typescript-eslint/parser', parserOptions: { sourceType: 'module', extraFileExtensions: ['.svelte'], project: ['tsconfig.json', 'tsconfig.node.json'], tsconfigRootDir: __dirname, }, }; ```
<!-- Hidable.svelte -->
<script lang="ts">
    export let hidden = true;
    export const show = () => {
        hidden = false;
    };
</script>

{#if !hidden}
    <slot />
{/if}

<!-- ShowOnMount.svelte -->
<script lang="ts">
    import Hidable from "$lib/Hidable.svelte";
    import { onMount } from "svelte";

    let hidable: Hidable | undefined;
    onMount(() => {
        hidable?.show();
    });
</script>

<Hidable bind:this={hidable}>
    <slot />
</Hidable>

What did you expect to happen?

No errors.

What actually happened?

/workspaces/reproduction/src/lib/ShowOnMount.svelte
  7:9  error  Unsafe call of an `any` typed value  @typescript-eslint/no-unsafe-call

Note: If you look at ShowOnMount.ts in the reproduction, you'll see that it generates the same error, so the issue does not only occur in .svelte files.

Link to GitHub Repo with Minimal Reproducible Example

https://github.com/Stadly/reproduction/tree/eslint-plugin-svelte/component-type-is-any

Additional comments

No response

ota-meshi commented 3 months ago

Duplicate of #298