From 7a84876ada11d339a9fbefdc3aaf4d28167192b3 Mon Sep 17 00:00:00 2001 From: "Benjamin W. Broersma" Date: Mon, 9 Dec 2019 15:15:49 +0100 Subject: [PATCH] Skip JS globals for InlineComponent nodes in warn_if_undefined. (#4071) --- src/compiler/compile/Component.ts | 2 +- .../samples/missing-component-global/input.svelte | 3 +++ .../missing-component-global/warnings.json | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test/validator/samples/missing-component-global/input.svelte create mode 100644 test/validator/samples/missing-component-global/warnings.json diff --git a/src/compiler/compile/Component.ts b/src/compiler/compile/Component.ts index 1c4b36360c..4402a4a947 100644 --- a/src/compiler/compile/Component.ts +++ b/src/compiler/compile/Component.ts @@ -1283,7 +1283,7 @@ export default class Component { if (this.var_lookup.has(name) && !this.var_lookup.get(name).global) return; if (template_scope && template_scope.names.has(name)) return; - if (globals.has(name)) return; + if (globals.has(name) && node.type !== 'InlineComponent') return; let message = `'${name}' is not defined`; if (!this.ast.instance) diff --git a/test/validator/samples/missing-component-global/input.svelte b/test/validator/samples/missing-component-global/input.svelte new file mode 100644 index 0000000000..5d17448bd4 --- /dev/null +++ b/test/validator/samples/missing-component-global/input.svelte @@ -0,0 +1,3 @@ +
+ +
\ No newline at end of file diff --git a/test/validator/samples/missing-component-global/warnings.json b/test/validator/samples/missing-component-global/warnings.json new file mode 100644 index 0000000000..c9de56619a --- /dev/null +++ b/test/validator/samples/missing-component-global/warnings.json @@ -0,0 +1,15 @@ +[{ + "code": "missing-declaration", + "message": "'String' is not defined. Consider adding a