Skip to content

Commit

Permalink
fix(compiler): For FatalDiagnosticError, hide the message field w…
Browse files Browse the repository at this point in the history
…ithout affecting the emit (#55160)

We want to hide `.message` from users, but the previous approach is not compatible with a specific [TS 3.7 flag](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#the-usedefineforclassfields-flag-and-the-declare-property-modifier) ("using class fields to specialize properties from base classes also won’t work"). I received a request from the TS team to fix this, so they can enable that flag.

Instead, we just override `message` to `never` in the .d.ts using `declare`.

PR Close #55160
  • Loading branch information
dylhunn authored and thePunderWoman committed Apr 2, 2024
1 parent c04ffb1 commit f824911
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/compiler-cli/src/ngtsc/diagnostics/src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class FatalDiagnosticError extends Error {

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

/**
* @internal
Expand Down

0 comments on commit f824911

Please sign in to comment.