( creationMode: boolean, oldValue: any, currValue: any, propName: string | undefined, lView: LView, )
| 63 | |
| 64 | /** Throws an ExpressionChangedAfterChecked error if checkNoChanges mode is on. */ |
| 65 | export function throwErrorIfNoChangesMode( |
| 66 | creationMode: boolean, |
| 67 | oldValue: any, |
| 68 | currValue: any, |
| 69 | propName: string | undefined, |
| 70 | lView: LView, |
| 71 | ): never { |
| 72 | const hostComponentDef = getDeclarationComponentDef(lView); |
| 73 | const componentClassName = hostComponentDef?.type?.name; |
| 74 | const field = propName ? ` for '${propName}'` : ''; |
| 75 | let msg = `ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value${field}: '${formatValue( |
| 76 | oldValue, |
| 77 | )}'. Current value: '${formatValue(currValue)}'.${ |
| 78 | componentClassName ? ` Expression location: ${componentClassName} component` : '' |
| 79 | }`; |
| 80 | if (creationMode) { |
| 81 | msg += |
| 82 | ` It seems like the view has been created after its parent and its children have been dirty checked.` + |
| 83 | ` Has it been created in a change detection hook?`; |
| 84 | } |
| 85 | throw new RuntimeError(RuntimeErrorCode.EXPRESSION_CHANGED_AFTER_CHECKED, msg); |
| 86 | } |
| 87 | |
| 88 | function formatValue(value: unknown): string { |
| 89 | let strValue: string = String(value); |
no test coverage detected
searching dependent graphs…