Within my interface definition, I have the following:
export interface IErrorIdentification {
errorClass?: new <T extends Error>() => T;
code?: string;
name?: string;
messageContains?: string;
}
However, I am facing issues with the errorClass
property. When I attempt to use it in this way:
context.errorMeta.add(
404,
{ errorClass: HandledError },
{ callback: e => cbResult }
);
The problem arises when the second parameter, { errorClass: HandledError }
, is supposed to adhere to the IErrorIdentificaiton type. This results in the following error:
https://i.sstatic.net/WwIQM.png
Interestingly, things run smoothly during runtime with this check:
e instanceof i.identifiedBy.errorClass
In addition, the error (e
) is recognized as an instance of Error
, which aligns with the fact that
HandledError</co de> is defined like so:</p>
<pre class="lang-js"><code>export class HandledError extends Error { ... }
Despite all these factors, I'm puzzled by the error message and its lack of clarity. Can anyone help me identify where I may be going wrong?