Skip to content

Property 'captureStackTrace' does not exist on type 'ErrorConstructor'. #3926

Closed
@Mamsaac

Description

@Mamsaac

I couldn't find more information on this bug by googling, so I will assume this is rather unusual.

While this doesn't ruin the compiling (thank you for that well thought design of "ignoring" errors when emitting), it is mostly an aesthetic issue.

I was porting the nodejs assert module to be an internal module, so that I can use it with other internal modules for testing purposes. Anyway, I wrote the following:

export interface IStackStartFunction {
  (actual: any, 
   expected: any, 
   message?: string,
   operator?: string,
   stackStartFunction?: (...args) => any): any;
}

export interface IAssertiorErrorOptions {
  name?: string;
  actual: any;
  expected: any;
  operator: string;
  message?: string;
  generatedMessage?: boolean;
  stackStartFunction?: IStackStartFunction;
}

export class AssertionError implements Error {
  public name: string;
  public message: string;

  constructor(public options: IAssertiorErrorOptions) {
    this.name = options.name = 'AssertionError';
    if (options.message) {
      options.message = options.message;
      options.generatedMessage = false;
    } else {
      options.message = getMessage(this);
      options.generatedMessage = true;
    }
    this.message = options.message;
    var stackStartFunction = options.stackStartFunction || fail;
    Error.captureStackTrace(this, stackStartFunction);
  }
}

It gives me the error:

assert.ts(102,13): error TS2339: Property 'captureStackTrace' does not exist on type 'ErrorConstructor'.

I noticed that supporting implementing types such as Error and other ES-6 specific types was added recently. I don't know enough about TypeScript internals to help with a PR.

Thanks for your time and help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions