I’ve created an Interface in Typescript NodeJS but I cannot wrap my head-around the error that says:
TypeError: exports.Something is not a constructor
interface Something {
name: string;
message: string;
stack?: string;
}
interface SomethingConstructor {
new(message?: string): Something;
(message?: string): Something;
readonly prototype: Something;
}
export declare var Something: SomethingConstructor;
This is what I have created as an Interface. And using it like so.
import { Something } from './dummy;
testFunction();
function testFunction() {
try {
const something = new Something("Here is a message");
console.log(something.message)
} catch (e) {
console.log('in catch block');
console.log(e);
}
}
I expected this would run and prints “Here is a message” in the console but throws the “is not a constructor” error. I might not know how I should use interfaces. Please shed light on how can I do something like it?