refactor(ivy): improve error message in `ngtsc`'s `findExportedNameOfNode()` (#28963)

PR Close #28963
This commit is contained in:
George Kalpakas 2019-03-18 16:24:55 +02:00 committed by Matias Niemelä
parent 4525619a73
commit a8d84660e5
2 changed files with 5 additions and 4 deletions

View File

@ -54,8 +54,8 @@ export interface ReferenceEmitStrategy {
/** /**
* Generates `Expression`s which refer to `Reference`s in a given context. * Generates `Expression`s which refer to `Reference`s in a given context.
* *
* A `ReferenceEmitter` uses one or more `ReferenceEmitStrategy` implementations to produce a * A `ReferenceEmitter` uses one or more `ReferenceEmitStrategy` implementations to produce an
* an `Expression` which refers to a `Reference` in the context of a particular file. * `Expression` which refers to a `Reference` in the context of a particular file.
*/ */
export class ReferenceEmitter { export class ReferenceEmitter {
constructor(private strategies: ReferenceEmitStrategy[]) {} constructor(private strategies: ReferenceEmitStrategy[]) {}

View File

@ -23,9 +23,10 @@ export function findExportedNameOfNode(
// Look for the export which declares the node. // Look for the export which declares the node.
const found = exports.find(sym => symbolDeclaresNode(sym, target, checker)); const found = exports.find(sym => symbolDeclaresNode(sym, target, checker));
if (found === undefined) { 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;
} }
/** /**