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 : did you resolve this? Why was this issue closed?
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
}
That should probably be added to node.d.ts.
yes, see documentation: https://nodejs.org/api/errors.html#errors_error_capturestacktrace_targetobject_constructoropt
@DanielRosenwasser Did this land in the node types? Not working for me.
@amcdnl @Mamsaac This helped - https://github.com/Microsoft/TypeScript/issues/1168#issuecomment-219296751
Most helpful comment
That should probably be added to
node.d.ts.