Skip to content

Commit

Permalink
fix(compiler): For FatalDiagnosticError, inherit the field in the c…
Browse files Browse the repository at this point in the history
…onstructor

We received a complaint from inside g3 that the previous code was not compatible with `useDefineForClassFields`. This should eliminate the used-before-initialization warning.
  • Loading branch information
dylhunn committed Apr 1, 2024
1 parent a64eca2 commit ac7f361
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/compiler-cli/src/ngtsc/diagnostics/src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ export class FatalDiagnosticError extends Error {
// when extending errors in TS and the workaround is to explicitly set the prototype.
// https://stackoverflow.com/questions/41102060/typescript-extending-error-class
Object.setPrototypeOf(this, new.target.prototype);

this.message = super.message as unknown as never
}

// Trying to hide `.message` from `Error` to encourage users to look
// at `diagnosticMessage` instead.
override message: never = this.message;
override message: never;

/**
* @internal
Expand Down

0 comments on commit ac7f361

Please sign in to comment.