Skip to content

Commit fd63bbd

Browse files
committed
fix warnings for props that are only used as stores (sveltejs#4021)
1 parent 13ef75b commit fd63bbd

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/compiler/compile/Component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ export default class Component {
465465
extract_names(declarator.id).forEach(name => {
466466
const variable = this.var_lookup.get(name);
467467
variable.export_name = name;
468-
if (variable.writable && !(variable.referenced || variable.referenced_from_script)) {
468+
if (variable.writable && !(variable.referenced || variable.referenced_from_script || variable.subscribable)) {
469469
this.warn(declarator, {
470470
code: `unused-export-let`,
471471
message: `${this.name.name} has unused export property '${name}'. If it is for external reference only, please consider using \`export const '${name}'\``
@@ -488,7 +488,7 @@ export default class Component {
488488
if (variable) {
489489
variable.export_name = specifier.exported.name;
490490

491-
if (variable.writable && !(variable.referenced || variable.referenced_from_script)) {
491+
if (variable.writable && !(variable.referenced || variable.referenced_from_script || variable.subscribable)) {
492492
this.warn(specifier, {
493493
code: `unused-export-let`,
494494
message: `${this.name.name} has unused export property '${specifier.exported.name}'. If it is for external reference only, please consider using \`export const '${specifier.exported.name}'\``

test/validator/samples/unreferenced-variables/input.svelte

+4
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@
1818
function foo() {
1919
return m + n + o;
2020
}
21+
export let p;
22+
export let q;
23+
$p;
2124
</script>
25+
{$q}

0 commit comments

Comments
 (0)