warn on template references to global variables (#2295)

pull/2321/head
Conduitry 6 years ago
parent fa79a72348
commit ecd7c6e9aa

@ -1182,7 +1182,7 @@ export default class Component {
if (name[0] === '$') return; // $$props 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 (template_scope && template_scope.names.has(name)) return;
if (globals.has(name)) return; if (globals.has(name)) return;

@ -0,0 +1,5 @@
<script>
console.log(potato);
</script>
<p>{potato}</p>

@ -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
}
}]
Loading…
Cancel
Save