fix(ngcc): log Angular error codes correctly (#34014)
Replaces the "TS-99" sequence with just "NG", so that error codes are logged correctly. PR Close #34014
This commit is contained in:
@ -6,10 +6,17 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import * as ts from 'typescript';
|
||||
|
||||
const ERROR_CODE_MATCHER = /(\u001b\[\d+m ?)TS-99(\d+: ?\u001b\[\d+m)/g;
|
||||
|
||||
/**
|
||||
* During formatting of `ts.Diagnostic`s, the numeric code of each diagnostic is prefixed with the
|
||||
* hard-coded "TS" prefix. For Angular's own error codes, a prefix of "NG" is desirable. To achieve
|
||||
* this, all Angular error codes start with "-99" so that the sequence "TS-99" can be assumed to
|
||||
* correspond with an Angular specific error code. This function replaces those occurrences with
|
||||
* just "NG".
|
||||
*
|
||||
* @param errors The formatted diagnostics
|
||||
*/
|
||||
export function replaceTsWithNgInErrors(errors: string): string {
|
||||
return errors.replace(ERROR_CODE_MATCHER, '$1NG$2');
|
||||
}
|
||||
|
Reference in New Issue
Block a user