If obj is a Typescript object (class instance), is there a way to do the same operation?
Your JavaScript is valid Typescript ( more ). This way you can use the same code as it.
Here is an example:
class Foo{ foo = 123 } const dict = new Foo(); const obj = {} as Foo; for (let key in dict) { if (obj.hasOwnProperty(key)) { obj[key] = dict[key]; } }
Note. I would recommend Object.keys(obj).forEach(k=> even for JavaScript, but that is not the question you ask here.
basarat
source share