From f64259c2968eca4439c5c6e3801f0b3f23fbdef0 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Sat, 11 Sep 2021 15:44:01 -0700 Subject: [PATCH] [chore] improve illegal declaration error message --- src/compiler/compile/Component.ts | 4 ++-- src/compiler/compile/compiler_errors.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/compile/Component.ts b/src/compiler/compile/Component.ts index 202e14fd9813..769b61c67b10 100644 --- a/src/compiler/compile/Component.ts +++ b/src/compiler/compile/Component.ts @@ -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'); diff --git a/src/compiler/compile/compiler_errors.ts b/src/compiler/compile/compiler_errors.ts index 54263c3eb911..f8d84431ddd6 100644 --- a/src/compiler/compile/compiler_errors.ts +++ b/src/compiler/compile/compiler_errors.ts @@ -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