I have to use an external js file in my TS component that it's like this:
var myObj;
function setObj(newObj) {
myObj= newObj;
return myObj;
}
function my_object() {
this.getA= function () {
return this.A;
}
this.getB= function () {
return this.B;
}
this.getC = function () {
return this.C;
}
}
I am able to call the function setObj
after declaring it this way in my.ts file:
declare function setObj(obj: MyObj);
But I need to call also the other functions (getA, getB, getC), but I don't know how.
I've tried returning the object when calling setObj and then call the function, like this:
let objReturned = setObj(myObj);
objReturned.getA()
but it tells me that getA
is not a function.
How can I call these nested functions inside the js?
You'll want something like:
declare interface SetObjC {
getC: () => void;
}
declare interface SetObjB {
getB: () => SetObjC
}
declare interface SetObjA {
getA: () => SetObjB;
}
declare function setObj(obj: MyObj): SetObjA;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.