fix(ivy): improve error message when NgModule properties are not arrays (#30796)
PR Close #30796
This commit is contained in:
parent
f0395836b6
commit
91008bd979
@ -396,7 +396,7 @@ export class NgModuleDecoratorHandler implements DecoratorHandler<NgModuleAnalys
|
|||||||
if (!Array.isArray(resolvedList)) {
|
if (!Array.isArray(resolvedList)) {
|
||||||
throw new FatalDiagnosticError(
|
throw new FatalDiagnosticError(
|
||||||
ErrorCode.VALUE_HAS_WRONG_TYPE, expr,
|
ErrorCode.VALUE_HAS_WRONG_TYPE, expr,
|
||||||
`Expected array when reading property ${arrayName}`);
|
`Expected array when reading the NgModule.${arrayName} of ${className}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
resolvedList.forEach((entry, idx) => {
|
resolvedList.forEach((entry, idx) => {
|
||||||
@ -413,14 +413,14 @@ export class NgModuleDecoratorHandler implements DecoratorHandler<NgModuleAnalys
|
|||||||
if (!this.isClassDeclarationReference(entry)) {
|
if (!this.isClassDeclarationReference(entry)) {
|
||||||
throw new FatalDiagnosticError(
|
throw new FatalDiagnosticError(
|
||||||
ErrorCode.VALUE_HAS_WRONG_TYPE, entry.node,
|
ErrorCode.VALUE_HAS_WRONG_TYPE, entry.node,
|
||||||
`Value at position ${idx} in the NgModule.${arrayName}s of ${className} is not a class`);
|
`Value at position ${idx} in the NgModule.${arrayName} of ${className} is not a class`);
|
||||||
}
|
}
|
||||||
refList.push(entry);
|
refList.push(entry);
|
||||||
} else {
|
} else {
|
||||||
// TODO(alxhub): Produce a better diagnostic here - the array index may be an inner array.
|
// TODO(alxhub): Produce a better diagnostic here - the array index may be an inner array.
|
||||||
throw new FatalDiagnosticError(
|
throw new FatalDiagnosticError(
|
||||||
ErrorCode.VALUE_HAS_WRONG_TYPE, expr,
|
ErrorCode.VALUE_HAS_WRONG_TYPE, expr,
|
||||||
`Value at position ${idx} in the NgModule.${arrayName}s of ${className} is not a reference: ${entry}`);
|
`Value at position ${idx} in the NgModule.${arrayName} of ${className} is not a reference: ${entry}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user