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

Syntax Error when using <h6> with inlines components #560

Closed
j3rem1e opened this issue Sep 23, 2020 · 3 comments · Fixed by #561
Closed

Syntax Error when using <h6> with inlines components #560

j3rem1e opened this issue Sep 23, 2020 · 3 comments · Fixed by #561
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.

Comments

@j3rem1e
Copy link
Contributor

j3rem1e commented Sep 23, 2020

Describe the bug

I have two components:

Child.svelte

<slot {t}/>

<script>
  const t = '';
</script>

Parent.svelte

<script>
import Child from './Child.svelte'
</script>

<h6><Child let:t>xx</Child><h6>

In VS Code, </Child> has the following errors:

  • Expected corresponding closing tag for JSX fragment
  • ';' expected
  • Identifier expected.
  • Unexpected token. Did you mean {'}'}or &rbrace;?
  • Expected corresponding JSX closing tag for 'Child'

svelte2tsx has generated this invalid code (the closure doesn't close correctly)

<h6><Child >{() => { let {t} = __sveltets_instanceOf(Child).$$slot_def['default'];<>xx</Child></>}}</h6></>);

To Reproduce
See the components above

Expected behavior
No errors in vscode

System (please complete the following information):

  • OS: Windows 10
  • IDE: VSCode
@j3rem1e j3rem1e added the bug Something isn't working label Sep 23, 2020
@j3rem1e
Copy link
Contributor Author

j3rem1e commented Sep 23, 2020

The bug is here : https://github.com/sveltejs/language-tools/blob/master/packages/svelte2tsx/src/htmlxtojsx/nodes/component.ts#L83

It should be

const closeTagStart = htmlx.lastIndexOf('<', slotEl.end - 1);

@dummdidumm
Copy link
Member

PR welcome if you solved it 🎉

@dummdidumm
Copy link
Member

Thanks for the PR! I'll close when it's released.

@dummdidumm dummdidumm reopened this Sep 23, 2020
@dummdidumm dummdidumm added the Fixed Fixed in master branch. Pending production release. label Sep 23, 2020
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

Successfully merging a pull request may close this issue.

2 participants