Skip to content

TS2589: Type instantiation is excessively deep and possibly infinite. #145

Description

@WBBB0730

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.
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions