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

Misformatted Snippet when using a typed instance of a Class #463

Closed
oliie opened this issue Sep 19, 2024 · 1 comment
Closed

Misformatted Snippet when using a typed instance of a Class #463

oliie opened this issue Sep 19, 2024 · 1 comment

Comments

@oliie
Copy link

oliie commented Sep 19, 2024

My relevant packages:

{
  "@sveltejs/kit": "^2.3.2"
  "svelte": "5.0.0-next.246",
  "prettier": "^3.3.3",
  "prettier-plugin-svelte": "^3.2.6",
}

When I have made a Snippet with typed arguments using an instance of a Class, the formatting fails and breaks the code.

Example before format:

{#snippet priceListItemsTabContent(title: string, tableInstance: InstanceType<new () => TableHandler<PriceListItem, PriceListItem>>, entityStatus: string)}

After format:

{#snippet priceListItemsTabContent(title: string, tableInstance: InstanceType<new ()}

This causes the code after to break. I've also noticed it sometimes created duplicated rows of code, but I cant provide an example for that.

I could solve it however by adding line breaks OR extracting the type to the script, causing the formatting to be fine.

Example 1 solution

{#snippet priceListItemsTabContent(
  title: string,
  tableInstance: InstanceType<new () => TableHandler<PriceListItem, PriceListItem>>,
  entityStatus: string
)}

Example 2 solution

<script lang="ts">
  type TableHandlerPriceListItem = InstanceType<new () => TableHandler<PriceListItem, PriceListItem>>;
  // ...
</script>

{#snippet priceListItemsTabContent(
    title: string,
    tableInstance: TableHandlerPriceListItem,
    entityStatus: string
)}

<!-- or as one line -->

{#snippet priceListItemsTabContent(title: string, tableInstance: TableHandlerPriceListItem, entityStatus: string)}
@dummdidumm
Copy link
Member

Closing as duplicate of #455 (fixed, was released just now)

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

2 participants