How can I convert a TypeScript object to a plain object?

后端 未结 3 1521
故里飘歌
故里飘歌 2021-02-18 21:59

I\'m using a JS library, specifically select2 that acts a tad differently than I\'d like if the objects I\'m passing it aren\'t plain objects. This is all checked b

3条回答
  •  春和景丽
    2021-02-18 22:23

    I know this is an old post, however in Nitzan's answer above, the typescript syntax checker seems to be ok with just doing the following:

    const plainObj:any = ClassObj;
    ClassObj.newProperty = "Test";
    

    So it seems like there is no real need to use Object.assign unless there is a difference I am unaware of.

提交回复
热议问题