From a8d84660e5088f0dca1845e24a0422fed080aa81 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Mon, 18 Mar 2019 16:24:55 +0200 Subject: [PATCH] refactor(ivy): improve error message in `ngtsc`'s `findExportedNameOfNode()` (#28963) PR Close #28963 --- packages/compiler-cli/src/ngtsc/imports/src/emitter.ts | 4 ++-- packages/compiler-cli/src/ngtsc/imports/src/find_export.ts | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/compiler-cli/src/ngtsc/imports/src/emitter.ts b/packages/compiler-cli/src/ngtsc/imports/src/emitter.ts index c52d5a4d39..f9052c8182 100644 --- a/packages/compiler-cli/src/ngtsc/imports/src/emitter.ts +++ b/packages/compiler-cli/src/ngtsc/imports/src/emitter.ts @@ -54,8 +54,8 @@ export interface ReferenceEmitStrategy { /** * Generates `Expression`s which refer to `Reference`s in a given context. * - * A `ReferenceEmitter` uses one or more `ReferenceEmitStrategy` implementations to produce a - * an `Expression` which refers to a `Reference` in the context of a particular file. + * A `ReferenceEmitter` uses one or more `ReferenceEmitStrategy` implementations to produce an + * `Expression` which refers to a `Reference` in the context of a particular file. */ export class ReferenceEmitter { constructor(private strategies: ReferenceEmitStrategy[]) {} diff --git a/packages/compiler-cli/src/ngtsc/imports/src/find_export.ts b/packages/compiler-cli/src/ngtsc/imports/src/find_export.ts index 71a4d45d35..681e49a3e6 100644 --- a/packages/compiler-cli/src/ngtsc/imports/src/find_export.ts +++ b/packages/compiler-cli/src/ngtsc/imports/src/find_export.ts @@ -23,9 +23,10 @@ export function findExportedNameOfNode( // Look for the export which declares the node. const found = exports.find(sym => symbolDeclaresNode(sym, target, checker)); if (found === undefined) { - throw new Error(`failed to find target in ${file.fileName}`); + throw new Error( + `Failed to find exported name of node (${target.getText()}) in '${file.fileName}'.`); } - return found !== undefined ? found.name : null; + return found.name; } /**