How can you override a constructor in TS? (Hard) Hint: use class decorators
function classDecorator(constructor:T) {
return class extends constructor {
newProperty = "new property";
hello = "override";
}
}
@classDecorator
class Greeter {
property = "property";
hello: string;
constructor(m: string) {
this.hello = m;
}
}console.log(new Greeter(“world”));
How do you define an interface for a callback in TypeScript when you work with Node.js?
interface ICallback {
{ error: Error, result?: number ) : void
});
Typescript programs are javascript programs: true or false
True
What is an advantage to provide types annotations?
Because they provide intention