Skip to content

form.store.subscribe changed type signature #2146

@mark1yan0

Description

@mark1yan0

Describe the bug

There's an issue when upgrading the package to v1.29.1 where form.store.subscribe() changed its signature and throws validtion errors. Here's an example

src/components/NewForm/Form.tsx:96:49 - error TS2339: Property 'currentVal' does not exist on type 'FormState<any, any, any, any, any, any, any, any, any, any, any>'.

96     const unsubscribe = form.store.subscribe(({ currentVal }) => {
                                                   ~~~~~~~~~~

src/components/NewForm/Form.tsx:103:18 - error TS2349: This expression is not callable.
  Type 'Subscription' has no call signatures.

103     return () => unsubscribe()
                     ~~~~~~~~~~~

Also no currentVal and prevVal are exposed in the callaback.

Is this api change intentional? If so, its not documented anywhere (or at least I did not found it)

Your minimal, reproducible example

https://codesandbox.io/p/sandbox/fgfrj5

Steps to reproduce

Upgrade the package to the latest version

Expected behavior

form.store.subscribe() should maintain the same signature as before so that currentVal and prevVal are available and also the unsubscribtion fn.

How often does this bug happen?

Only once

Screenshots or Videos

No response

Platform

Development with react

TanStack Form adapter

react-form

TanStack Form version

v1.29.1

TypeScript version

v6.0.3

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions