Typescript objects serialization?

前端 未结 5 1392
隐瞒了意图╮
隐瞒了意图╮ 2021-02-02 06:40

Are there any means for JSON serialization/deserialization of Typescript objects so that they don\'t loose type information? Simple JSON.parse(JSON.stringify) has t

5条回答
  •  北恋
    北恋 (楼主)
    2021-02-02 07:09

    The AQuirky answer works for me. You may have some troubles with the Object.assign method. I had to modify my tsconfig.json to include:

    "compilerOptions": {
        ...
        "lib": ["es2015"],
        ...
    }
    

提交回复
热议问题