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

Cannot use TypeScript type annotations in template #525

Open
shaozi opened this issue Jun 8, 2022 · 3 comments
Open

Cannot use TypeScript type annotations in template #525

shaozi opened this issue Jun 8, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@shaozi
Copy link

shaozi commented Jun 8, 2022

Describe the bug
When a function is used in a component props, its parameter cannot have a type. in the following code, x={(d: Point) => d.x} shows an error of:

Unexpected tokensvelte(parse-error)
Unexpected tokents(-1)
<Pancake.SvgLine
    data={[...points, { [x]: maxx, [field.key]: 0 }]}
    x={(d: Point) => d.x}
    y={(d) => d.y}
    let:d
    >
       <path class="data" {d} />
</Pancake.SvgLine>

Logs
Please include browser console and server logs around the time this bug occurred.

To Reproduce

  1. create a brand new svelte ts project.
  2. use a function in a prop and add a type to the parameter.
  3. See the error

Version
svelte-preprocess version (Please check you can reproduce the issue with the latest release!)

latest 4.10.7

@bluwy
Copy link
Member

bluwy commented Jun 8, 2022

TypeScript is not supported in template as noted at https://github.com/sveltejs/svelte-preprocess/blob/main/docs/preprocessing.md#typescript---limitations

@dummdidumm dummdidumm added the enhancement New feature or request label Jun 13, 2022
@dummdidumm dummdidumm changed the title Type parameters in prop function raise unexpected token parser error Cannot use TypeScript type annotations in template Jun 13, 2022
@dummdidumm
Copy link
Member

Blocked by sveltejs/svelte#4701

@dummdidumm
Copy link
Member

Svelte 5 supports type annotations in the template

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

No branches or pull requests

3 participants