[chore] improve illegal declaration error message

pull/6722/head
Ben McCann 5 years ago
parent c040f130b7
commit 42a8b010c9

2
package-lock.json generated

@ -5,7 +5,7 @@
"requires": true,
"packages": {
"": {
"version": "3.41.0",
"version": "3.42.5",
"license": "MIT",
"devDependencies": {
"@ampproject/remapping": "^0.3.0",

@ -587,7 +587,7 @@ export default class Component {
scope.declarations.forEach((node, name) => {
if (name[0] === '$') {
return this.error(node as any, compiler_errors.illegal_declaration);
return this.error(node as any, compiler_errors.illegal_declaration(name));
}
const writable = node.type === 'VariableDeclaration' && (node.kind === 'var' || node.kind === 'let');
@ -660,7 +660,7 @@ export default class Component {
instance_scope.declarations.forEach((node, name) => {
if (name[0] === '$') {
return this.error(node as any, compiler_errors.illegal_declaration);
return this.error(node as any, compiler_errors.illegal_declaration(name));
}
const writable = node.type === 'VariableDeclaration' && (node.kind === 'var' || node.kind === 'let');

@ -174,10 +174,10 @@ export default {
code: 'default-export',
message: 'A component cannot have a default export'
},
illegal_declaration: {
illegal_declaration: (name: string) => ({
code: 'illegal-declaration',
message: 'The $ prefix is reserved, and cannot be used for variable and import names'
},
message: `The $ prefix is reserved, and cannot be used for variable and import names, but found ${name}`
}),
illegal_subscription: {
code: 'illegal-subscription',
message: 'Cannot reference store value inside <script context="module">'

@ -5,5 +5,5 @@ export default {
count: writable(0)
},
error: 'The $ prefix is reserved, and cannot be used for variable and import names'
error: 'The $ prefix is reserved, and cannot be used for variable and import names, but found $count'
};

Loading…
Cancel
Save