Merge pull request #2045 from sveltejs/gh-2037

insert semicolon where necessary when initing props
pull/2058/head
Rich Harris 6 years ago committed by GitHub
commit 11969cdfe7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -744,10 +744,14 @@ export default class Component {
});
}
const suffix = code.original[declarator.end] === ';'
? ` = $$props`
: ` = $$props;`
if (declarator.id.end === declarator.end) {
code.appendLeft(declarator.end, ' = $$props');
code.appendLeft(declarator.end, suffix);
} else {
code.overwrite(declarator.id.end, declarator.end, ' = $$props');
code.overwrite(declarator.id.end, declarator.end, suffix);
}
}
@ -823,7 +827,8 @@ export default class Component {
});
if (combining) {
code.appendLeft(c, ' } = $$props');
const suffix = code.original[c] === ';' ? ` } = $$props` : ` } = $$props;`;
code.appendLeft(c, suffix);
}
});
}

@ -0,0 +1,7 @@
export default {
props: {
name: 'world'
},
html: `<h1>Hello world!</h1>`
};

@ -0,0 +1,6 @@
<h1>Hello {name}!</h1>
<script>
export let name
(() => {})()
</script>
Loading…
Cancel
Save