@@ -38,23 +38,26 @@ For example, if you enter `*.svelte` template to listen for input events:
3838
3939``` svelte
4040<script lang="ts">
41- function inputHandler () {
42- // process
43- }
41+ function inputHandler() {
42+ // process
43+ }
4444</script>
45- <input on:input={inputHandler}>
45+
46+ <input on:input={inputHandler} />
4647```
4748
4849Parse the following virtual script code as a script:
4950
5051``` ts
51-
52- function inputHandler () {
53- // process
54- }
55- ;function $_render1(){
56-
57- (inputHandler ) as ((e : ' input' extends keyof HTMLElementEventMap ? HTMLElementEventMap [' input' ] : CustomEvent <any >) => void );
52+ function inputHandler() {
53+ // process
54+ }
55+ function $_render1() {
56+ inputHandler as (
57+ e : " input" extends keyof HTMLElementEventMap
58+ ? HTMLElementEventMap [" input" ]
59+ : CustomEvent <any >,
60+ ) => void ;
5861}
5962```
6063
@@ -78,25 +81,24 @@ For example, when using `{#each}` and `{@const}`:
7881
7982``` svelte
8083<script lang="ts">
81- const array = [1, 2, 3]
84+ const array = [1, 2, 3];
8285</script>
86+
8387{#each array as e}
84- {@const ee = e * 2}
85- {ee}
88+ {@const ee = e * 2}
89+ {ee}
8690{/each}
8791```
8892
8993Parse the following virtual script code as a script:
9094
9195``` ts
92-
93- const array = [1 , 2 , 3 ]
94- ;function $_render1(){
95-
96- Array .from (array ).forEach ((e ) => {
96+ const array = [1 , 2 , 3 ];
97+ function $_render1() {
98+ Array .from (array ).forEach ((e ) => {
9799 const ee = e * 2 ;
98- ( ee ) ;
99- });
100+ ee ;
101+ });
100102}
101103```
102104
@@ -121,8 +123,9 @@ TypeScript's type inference is pretty good, so parsing Svelte as-is gives some w
121123
122124e.g.
123125
126+ <!-- prettier-ignore -->
124127``` ts
125- export let foo: { bar: number } | null = null
128+ export let foo: { bar: number } | null = null ;
126129
127130$ : console .log (foo && foo .bar );
128131 // ^ never type
@@ -139,13 +142,13 @@ For example:
139142
140143``` svelte
141144<script lang="ts">
142- export let foo: { bar: number } | null = null
145+ export let foo: { bar: number } | null = null;
143146
144- $: console.log(foo && foo.bar);
147+ $: console.log(foo && foo.bar);
145148
146- $: r = foo && foo.bar;
149+ $: r = foo && foo.bar;
147150
148- $: ({ bar: n } = foo || { bar: 42 });
151+ $: ({ bar: n } = foo || { bar: 42 });
149152</script>
150153
151154{foo && foo.bar}
@@ -154,26 +157,24 @@ $: ({ bar: n } = foo || { bar: 42 });
154157Parse the following virtual script code as a script:
155158
156159``` ts
157-
158- export let foo: { bar: number } | null = null
160+ export let foo: { bar: number } | null = null ;
159161
160- $ : function $_reactiveStatementScopeFunction1(){
161- console .log (foo && foo .bar );
162+ $ : function $_reactiveStatementScopeFunction1() {
163+ console .log (foo && foo .bar );
162164}
163165
164- $ : let r = $_reactiveVariableScopeFunction2 ();
165- function $_reactiveVariableScopeFunction2(){
166- let $_tmpVar3;
167- return ($_tmpVar3 = foo && foo .bar );
166+ $ : let r = $_reactiveVariableScopeFunction2 ();
167+ function $_reactiveVariableScopeFunction2() {
168+ let $_tmpVar3;
169+ return ($_tmpVar3 = foo && foo .bar );
168170}
169171
170- $ : let { bar : n } = $_reactiveVariableScopeFunction4 ();
171- function $_reactiveVariableScopeFunction4(){
172- let $_tmpVar5;
173- return ($_tmpVar5 = foo || { bar: 42 });
172+ $ : let { bar : n } = $_reactiveVariableScopeFunction4 ();
173+ function $_reactiveVariableScopeFunction4() {
174+ let $_tmpVar5;
175+ return ($_tmpVar5 = foo || { bar: 42 });
174176}
175- ;function $_render6(){
176-
177- (foo && foo .bar );
177+ function $_render6() {
178+ foo && foo .bar ;
178179}
179180```
0 commit comments