I want to type the native Class Error. The property cause in Error has the type unknown and I want it to be a enum I created myself.
The Error object look like this:
interface Error {
name: string;
message: string;
stack?: string;
cause: unkownwn;
}
I want to override cause using a declaration file, how can i do this?
You can't change the type of an existing property.
You can add a property:
But changing a type of existing one:
Results in an error:
You can of course have your own interface which extends an existing one. In that case, you can override a type only to a compatible type, for example: