diff --git a/src/diagnosticMessages.json b/src/diagnosticMessages.json index 5ff99ccc9e..5c9a03e6f2 100644 --- a/src/diagnosticMessages.json +++ b/src/diagnosticMessages.json @@ -10,6 +10,7 @@ "Shared memory requires feature 'threads' to be enabled.": 108, "Transform '{0}': {1}": 109, "Start function name '{0}' is invalid or conflicts with another export.": 110, + "Element '{0}' not found.": 111, "Conversion from type '{0}' to '{1}' requires an explicit cast.": 200, "Conversion from type '{0}' to '{1}' will require an explicit cast when switching between 32/64-bit.": 201, diff --git a/src/program.ts b/src/program.ts index 6bb1dea523..4e28ba2478 100644 --- a/src/program.ts +++ b/src/program.ts @@ -1421,7 +1421,7 @@ export class Program extends DiagnosticEmitter { if (elementsByName.has(name)) { elementsByName.set(alias, assert(elementsByName.get(name))); } else { - throw new Error("no such global element: " + name); + this.error(DiagnosticCode.Element_0_not_found, null, name); } } }