diff --git a/CHANGELOG.md b/CHANGELOG.md index 755de01..44edf69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # prettier-plugin-svelte changelog +## 3.3.2 + +- (fix) Svelte 5: handle type annotations on Svelte control flow blocks + ## 3.3.1 - (feat) Svelte 5: support upcoming `bind:value={get, set}` diff --git a/src/print/index.ts b/src/print/index.ts index 3e25ab5..e6c6a3e 100644 --- a/src/print/index.ts +++ b/src/print/index.ts @@ -1177,7 +1177,12 @@ function printJS(path: FastPath, print: PrintFn, name: string) { function expandNode(node: any, original: string): string { let str = _expandNode(node); if (node?.typeAnnotation) { - str += ': ' + original.slice(node.typeAnnotation.start, node.typeAnnotation.end); + str += + ': ' + + original.slice( + node.typeAnnotation.typeAnnotation.start, + node.typeAnnotation.typeAnnotation.end, + ); } return str; } diff --git a/test/printer/samples/typescript-template.html.skip b/test/printer/samples/typescript-template.html.skip index ce5c104..4bc1be1 100644 --- a/test/printer/samples/typescript-template.html.skip +++ b/test/printer/samples/typescript-template.html.skip @@ -7,3 +7,15 @@ > + +{#await promise} +

Waiting

+{:then num: number} +

{num}

+{:catch error: Error} +

Error: {error.message}

+{/await} + +{#each [] as x: number} + {x} +{/each}