Skip to content

Commit

Permalink
fix warnings for props that are only used as stores (#4021)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conduitry committed Dec 4, 2019
1 parent 185ff4a commit e996ef7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/compiler/compile/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ export default class Component {
extract_names(declarator.id).forEach(name => {
const variable = this.var_lookup.get(name);
variable.export_name = name;
if (variable.writable && !(variable.referenced || variable.referenced_from_script)) {
if (variable.writable && !(variable.referenced || variable.referenced_from_script || variable.subscribable)) {
this.warn(declarator, {
code: `unused-export-let`,
message: `${this.name.name} has unused export property '${name}'. If it is for external reference only, please consider using \`export const '${name}'\``
Expand All @@ -488,7 +488,7 @@ export default class Component {
if (variable) {
variable.export_name = specifier.exported.name;

if (variable.writable && !(variable.referenced || variable.referenced_from_script)) {
if (variable.writable && !(variable.referenced || variable.referenced_from_script || variable.subscribable)) {
this.warn(specifier, {
code: `unused-export-let`,
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}'\``
Expand Down
4 changes: 4 additions & 0 deletions test/validator/samples/unreferenced-variables/input.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@
function foo() {
return m + n + o;
}
export let p;
export let q;
$p;
</script>
{$q}

0 comments on commit e996ef7

Please sign in to comment.