Is there any way to target the plain JavaScript object type in TypeScript?

前端 未结 3 1040
梦谈多话
梦谈多话 2021-02-13 09:46

I\'m trying to write a function where I\'d like to indicate that it returns some kind of plain JavaScript object. The object\'s signature is unknown, and not interestin

3条回答
  •  无人共我
    2021-02-13 10:10

    You can try recursive type (naive solution)

    type SerializableObject = { [x: string]: SerializableObject | number | string | [] };
    

    Not good, not terrible :)

提交回复
热议问题