Answer the question
In order to leave comments, you need to log in
Are the object properties defined correctly in the example?
There is a code, and I have doubts about its correctness. Namely, in the getCounter function, we define the let counter function, in which we later define properties, without calling it in the getCounter function itself, so, is it possible to set properties for the function in this way, without knowing what else it will return . And what does it do <counter>
before the function in this example?
interface Counter {
(start: number): string;
interval: number;
reset(): void;
}
function getCounter(): Counter {
let counter = <counter>function (start: number) { };
counter.interval = 123;
counter.reset = function () { };
return counter;
}
let c = getCounter();
c(10);
c.reset();
c.interval = 5.0;
</counter>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question