TypeScript Version: 2.1.4
Code
Given the following definition
export default class ExtendedError extends Error {
public get something(): number {
return 42;
}
public doSomething() {
}
}
I get the following output for 2.0.3
const extendedErrorInstance = new ExtendedError();
console.log("Is instanceof ExtendedError:", extendedErrorInstance instanceof ExtendedError);
// outputs "Is instanceof ExtendedError: true"
console.log("Is instanceof Error:", extendedErrorInstance instanceof Error);
// outputs "Is instanceof Error: true"
console.log("Value of something:", extendedErrorInstance.something);
// outputs "Value of something: 42"
console.log("Do something:", extendedErrorInstance.doSomething());
// executes function and outputs "Do something: undefined"
However for version 2.1.1 and 2.1.4 I get the following
const extendedErrorInstance = new ExtendedError();
console.log("Is instanceof ExtendedError:", extendedErrorInstance instanceof ExtendedError);
// outputs "Is instanceof ExtendedError: false"
console.log("Is instanceof Error:", extendedErrorInstance instanceof Error);
// outputs "Is instanceof Error: true"
console.log("Value of something:", extendedErrorInstance.something);
// outputs "Value of something: undefined"
console.log("Do something:", extendedErrorInstance.doSomething());
// throws error "TypeError: extendedErrorInstance.doSomething is not a function"
Expected behavior:
The extended error to behave as in the first example
Actual behavior:
It seems as if the error has not been extended at all
Thanks very much for your assistance in advance.
James
TypeScript Version: 2.1.4
Code
Given the following definition
I get the following output for 2.0.3
However for version 2.1.1 and 2.1.4 I get the following
Expected behavior:
The extended error to behave as in the first example
Actual behavior:
It seems as if the error has not been extended at all
Thanks very much for your assistance in advance.
James