Skip to content

Commit

Permalink
Make TSError diagnosticText non-enumerable to prevent it from log…
Browse files Browse the repository at this point in the history
…ging below stack trace (#1632)

* Make tserror diagnosticText non-enumerable to prevent it from logging below stack trace in errors

* lint-fix
  • Loading branch information
cspotcode committed Feb 7, 2022
1 parent 26c3774 commit 2ffcbe3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,15 @@ export const DEFAULTS: RegisterOptions = {
*/
export class TSError extends BaseError {
name = 'TSError';
diagnosticText!: string;

constructor(public diagnosticText: string, public diagnosticCodes: number[]) {
constructor(diagnosticText: string, public diagnosticCodes: number[]) {
super(`⨯ Unable to compile TypeScript:\n${diagnosticText}`);
Object.defineProperty(this, 'diagnosticText', {
configurable: true,
writable: true,
value: diagnosticText,
});
}

/**
Expand Down

0 comments on commit 2ffcbe3

Please sign in to comment.