An interface TypeScript , . 7 TypeScript, , .
, "" interface . , , , . :
var body = <IBody> e;
, , IBody. , , e Element , , , Element , /, IBody. , - , IBody, .
, Element , IBody, . , . , , any, , , IBody, script.
Element , IBody. any:
function someFeature(e: any) {
}
, IBody:
function someFeature(e: any) {
var body :IBody = <IBody> e;
// do something
}
, , prototype . , interface TypeScript , , . , .
:
function someFeature(e: any) {
var body = <IBody> e;
if (typeof (body.someFunctionOnBodyInterface) === "undefined") {
throw new Error("Yikes!");
}
body.someFunctionOnBodyInterface();
}