Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[
{
"range": {
"start": { "line": 26, "character": 7 },
"end": { "line": 26, "character": 24 }
"start": { "line": 29, "character": 7 },
"end": { "line": 29, "character": 24 }
},
"severity": 1,
"source": "ts",
Expand All @@ -12,8 +12,8 @@
},
{
"range": {
"start": { "line": 30, "character": 7 },
"end": { "line": 30, "character": 24 }
"start": { "line": 33, "character": 7 },
"end": { "line": 33, "character": 24 }
},
"severity": 1,
"source": "ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[
{
"range": {
"start": { "line": 26, "character": 7 },
"end": { "line": 26, "character": 24 }
"start": { "line": 29, "character": 7 },
"end": { "line": 29, "character": 24 }
},
"severity": 1,
"source": "ts",
Expand All @@ -12,8 +12,8 @@
},
{
"range": {
"start": { "line": 30, "character": 7 },
"end": { "line": 30, "character": 24 }
"start": { "line": 33, "character": 7 },
"end": { "line": 33, "character": 24 }
},
"severity": 1,
"source": "ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const badOptions = {
{#each simpleOptions as option, i}
<div>{option}, {i}</div>
{/each}
{#each simpleOptions as option, i (i)}
<div>{option}, {i}</div>
{/each}

<!-- Unions of Arrays work fine -->
{#each complexOptions as option, i (typeof option === "string" ? option : option.value)}
Expand Down
6 changes: 3 additions & 3 deletions packages/svelte2tsx/src/htmlxtojsx_v2/nodes/EachBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ export function handleEach(str: MagicString, eachBlock: BaseNode): void {
`${containsComma ? ')' : ''})){`
];
}
if (eachBlock.key) {
transforms.push([eachBlock.key.start, eachBlock.key.end], ';');
}
if (eachBlock.index) {
const indexStart = str.original.indexOf(eachBlock.index, eachBlock.context.end);
const indexEnd = indexStart + eachBlock.index.length;
transforms.push('let ', [indexStart, indexEnd], ' = 1;');
}
if (eachBlock.key) {
transforms.push([eachBlock.key.start, eachBlock.key.end], ';');
}
transform(str, eachBlock.start, startEnd, startEnd, transforms);

const endEach = str.original.lastIndexOf('{', eachBlock.end - 1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
for(const item of __sveltets_2_ensureArray(items)){item.id;let i = 1;
for(const item of __sveltets_2_ensureArray(items)){let i = 1;item.id;
{ svelteHTML.createElement("div", {});item;i; }
}
{ svelteHTML.createElement("div", {}); }
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
for(const item of __sveltets_2_ensureArray(items)){item.id;let i = 1;
for(const item of __sveltets_2_ensureArray(items)){let i = 1;item.id;
{ svelteHTML.createElement("div", {});item;i; }
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if(hello){
for(const hello of __sveltets_2_ensureArray(items)){hello.id;let i = 1;
for(const hello of __sveltets_2_ensureArray(items)){let i = 1;hello.id;
{ svelteHTML.createElement("div", {});hello;i; }
if(hello){
for(const hello of __sveltets_2_ensureArray(items)){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if(hello){
for(const item of __sveltets_2_ensureArray(items)){item.id;let i = 1;
for(const item of __sveltets_2_ensureArray(items)){let i = 1;item.id;
{ svelteHTML.createElement("div", {});item;i; }
}
if(hi && bye){
Expand Down