Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Mamsaac opened this issue Jul 19, 2015 · 6 comments
Closed
Labels
Question An issue which isn't directly actionable in code

Comments

@Mamsaac
Copy link

Mamsaac commented Jul 19, 2015

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.

@Mamsaac Mamsaac closed this as completed Jul 19, 2015
@LaurensRietveld
Copy link

@Mamsaac : did you resolve this? Why was this issue closed?

@mhegazy
Copy link
Contributor

mhegazy commented Jan 5, 2016

captureStackTrace is not a standard property, it is a v8-specific one. you should be able to add definition to it as:

interface ErrorConstructor {
    captureStackTrace(thisArg: any, func: any): void
}

@mhegazy mhegazy added the Question An issue which isn't directly actionable in code label Jan 5, 2016
@DanielRosenwasser
Copy link
Member

That should probably be added to node.d.ts.

@mhegazy
Copy link
Contributor

mhegazy commented Jan 5, 2016

@amcdnl
Copy link

amcdnl commented Aug 31, 2016

@DanielRosenwasser Did this land in the node types? Not working for me.

@paambaati
Copy link

paambaati commented Jan 29, 2018

@amcdnl @Mamsaac This helped - #1168 (comment)

@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

6 participants