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

Slot prop not found on slot element itself #817

Closed
brunnerh opened this issue Feb 14, 2021 · 3 comments
Closed

Slot prop not found on slot element itself #817

brunnerh opened this issue Feb 14, 2021 · 3 comments
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.

Comments

@brunnerh
Copy link
Member

Describe the bug
Slot properties are only found within the slot element, but not on the element itself. Svelte allows using the property on the element, so the error is simply a bit misleading. Possibly only surfaced as error when using TypeScript with sufficiently strict settings.

To Reproduce
Create a component with slot properties and use the property on the element declaring the property (here the error in on the class usage):

<Component n={10}>
	<div slot="item" let:zebra class={zebra}>Hello {zebra}</div>
</Component>

[REPL]

Expected behavior
Slot property is in scope and no error is raised.

Screenshots
image

System (please complete the following information):

  • OS: Windows 10 64bit
  • IDE: VSCode
  • Plugin/Package: Svelte for VSCode
@brunnerh brunnerh added the bug Something isn't working label Feb 14, 2021
@dummdidumm
Copy link
Member

We need to pull the jsx-transformation on level up, surrounding the tag. So for example in this test it should become

<>{() => { let {thing:{ a }} = __sveltets_instanceOf(Component).$$slot_def['default'];<><Component>
    <h1>Hello { a }</h1>
</Component></>}}</>

dummdidumm pushed a commit to dummdidumm/language-tools that referenced this issue Feb 19, 2021
@dummdidumm dummdidumm added the Fixed Fixed in master branch. Pending production release. label Feb 19, 2021
@brunnerh
Copy link
Member Author

@dummdidumm Thank you for the fix

I just tested this and if the let:prop is after its usage, you still get a svelte warning instead of a type error:

'prop' is not defined [svelte(missing-declaration)]

Example screenshot:

image

The generated output works regardless of the order, though. Of course i can just reorder the attributes to get rid of the error as a workaround.

@dummdidumm
Copy link
Member

This is a Svelte compiler bug, I created sveltejs/svelte#6009 for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.
Projects
None yet
Development

No branches or pull requests

2 participants