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

Extract slot prop types from $$Slots #273

Open
marekdedic opened this issue Feb 6, 2023 · 1 comment
Open

Extract slot prop types from $$Slots #273

marekdedic opened this issue Feb 6, 2023 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@marekdedic
Copy link
Contributor

Description

In sveltejs/eslint-plugin-svelte#347 I proposed a rule to require slots and their props to be typed. In this package, those types should be used if they're present.

An example of what currently doesn't work:

App.svelte:

<Component let:arrayProp={arrayValue}>
  {#each arrayValue.filter( (val) => val.length > 10 ) as val} <!-- HERE -->
    {val}
  {/each}
</Component>

Component.svelte:

<script lang="ts">
  interface $$Slots {
    default: { arrayProp: Array<string> };
  }
</script>

<slot arrayProp={["Hello", "World", "Hello World"]} />

Here, on the marked line, I get the eslint error @typescript-eslint/no-unsafe-call - I presume that's because the parser does not infer that arrayValue is of type Array<string> and leaves it as any...

@marekdedic marekdedic added the enhancement New feature or request label Feb 6, 2023
@marekdedic
Copy link
Contributor Author

Actually, in general, the parser should probably eventually support the whole RFC...

@ota-meshi ota-meshi added the help wanted Extra attention is needed label Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants