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

ESlint false positive with custom component. #194

Open
ptrxyz opened this issue Nov 3, 2022 · 0 comments
Open

ESlint false positive with custom component. #194

ptrxyz opened this issue Nov 3, 2022 · 0 comments

Comments

@ptrxyz
Copy link

ptrxyz commented Nov 3, 2022

ESlint somehow reports an unsafe-member-access error when I try to access a exported property of a componente. Consider this component:

<script lang="ts">
    // comp.svelte
    export const value1 = 3
    export const api = {
        value2: 3,
        get value3() {
            return 1
        },
    }
</script>

which is imported here:

<script lang="ts">
    // +page.svelte
    import Comp from 'comp.svelte'

    let x: Comp

    $: if (x) console.log(x.value1, x.api.value2, x.api.value3, x.something)
</script>

<Comp bind:this={x} />

If I run svelte-kit sync; pnpm lint I get an error:

/tmp/eslint-test/src/routes/+page.svelte
  6:37  error  Unsafe member access .value2 on an `any` value  @typescript-eslint/no-unsafe-member-access
  6:51  error  Unsafe member access .value3 on an `any` value  @typescript-eslint/no-unsafe-member-access

However api is actually typed. Typescript also doesn't seem to complain:

image

Does anyone know what's going wrong here?

--
A minimal example based on the SvelteKit template can be found here:
Github-Repo
StackBlitz

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

No branches or pull requests

1 participant