diff --git a/src/compile/Component.ts b/src/compile/Component.ts index f8ee5a0b78..21f0b6ef05 100644 --- a/src/compile/Component.ts +++ b/src/compile/Component.ts @@ -1182,7 +1182,7 @@ export default class Component { if (name[0] === '$') return; // $$props } - if (this.var_lookup.has(name)) return; + 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; diff --git a/test/validator/samples/undefined-value-global/input.svelte b/test/validator/samples/undefined-value-global/input.svelte new file mode 100644 index 0000000000..44e7332bf5 --- /dev/null +++ b/test/validator/samples/undefined-value-global/input.svelte @@ -0,0 +1,5 @@ + + +

{potato}

diff --git a/test/validator/samples/undefined-value-global/warnings.json b/test/validator/samples/undefined-value-global/warnings.json new file mode 100644 index 0000000000..ee9e3d6c90 --- /dev/null +++ b/test/validator/samples/undefined-value-global/warnings.json @@ -0,0 +1,15 @@ +[{ + "code": "missing-declaration", + "message": "'potato' is not defined", + "pos": 46, + "start": { + "line": 5, + "column": 4, + "character": 46 + }, + "end": { + "line": 5, + "column": 10, + "character": 52 + } +}]