我对TypeScript非常陌生,我非常喜欢它,尤其是在Javascript中实现OOP是多么容易.然而,当涉及到使用尖括号时,我一直在试图弄清楚它的语义.
从他们的文档中,我看到了以下几个例子:
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;
}
和
interface Square extends Shape, PenStroke {
sideLength: number;
}
let square = <Square>{};
I am having trouble underst和ing what this exactly means or the way to think of/underst和 it.
谁能给我解释一下吗?