From e996ef750d31ada1ef2dfefd4aae06010dbd2ea6 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sat, 30 Nov 2019 19:55:49 -0500 Subject: [PATCH] fix warnings for props that are only used as stores (#4021) --- src/compiler/compile/Component.ts | 4 ++-- test/validator/samples/unreferenced-variables/input.svelte | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/compiler/compile/Component.ts b/src/compiler/compile/Component.ts index cd97c8dd8e..de5400367d 100644 --- a/src/compiler/compile/Component.ts +++ b/src/compiler/compile/Component.ts @@ -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}'\`` @@ -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}'\`` diff --git a/test/validator/samples/unreferenced-variables/input.svelte b/test/validator/samples/unreferenced-variables/input.svelte index 1180f6ef1a..8c9e0b15f3 100644 --- a/test/validator/samples/unreferenced-variables/input.svelte +++ b/test/validator/samples/unreferenced-variables/input.svelte @@ -18,4 +18,8 @@ function foo() { return m + n + o; } + export let p; + export let q; + $p; +{$q}