When my data type contains a recursive JSONValue property, modifying the draft will result in the following error:
TS2589: Type instantiation is excessively deep and possibly infinite.
This issue is similar to the one mentioned in immerjs/immer#839
Here is the sample code that produces the problem:
import type { Message } from 'ai'
const [messages, setMessages] = useImmer<Message[]>([])
setMessages((messages) => {
messages.push(message) // TS2589: Type instantiation is excessively deep and possibly infinite.
})