Reputation: 1486
I am creating an Application using react-redux. In that i am using typescript and immutable.js. When i use immutable methods like updateIn(), for a typed object, it is throwing error.
Following is the code which i tried:
interface aType{
id: number
}
function randFun(a:aType){
a = a.updateIn([....]); //It is throwing error in this line of code.
}
randFun({id:2});
Property 'updateIn' doesn't exist in on type {...}
How can i get rid of this error???
Upvotes: 1
Views: 3765
Reputation: 28686
As for TypeScript, it's because updateIn
is not defined in aType
interface. To fix it, you can write:
interface aType{
id: number,
updateIn(n: number): aType
}
function randFun(a:aType){
let n = 5;
a = a.updateIn(n); // No error here
}
randFun({id:2}); // This still need to be fixed!
However, it can't work in JavaScript too because you can't call updateIn
on {id:2}
object.
Upvotes: 1