Skip to content

acceptHMRUpdate skips optional attributes without default values #2611

Open
@bodograumann

Description

Reproduction

https://github.com/bodograumann/pinia-hmr-optional-attributes

Steps to reproduce the bug

  1. git clone https://github.com/bodograumann/pinia-hmr-optional-attributes
  2. cd pinia-hmr-optional-attributes
  3. npm install
  4. npm run dev
  5. xdg-open http://localhost:5173
  6. Press the "Increment" button. Sign says "positive".
  7. touch src/store/counter.ts

Expected behavior

All the state should be preserved.

Actual behavior

counter.nr is preserved as 1, but counter.sign is lost. The page shows -, while it should show positive.

Additional information

The relevant code is here:

if (!(key in newState)) {
continue
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    • Status

      💬 In discussion

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions