Skip to content

feat(dx): warn when storeToRefs() receives a plain object #3074

@VIPAX-JIT

Description

@VIPAX-JIT

Reproduction

This is not a runtime bug, but a DX issue. ```ts import { defineStore, storeToRefs } from 'pinia' const useCounter = defineStore('counter', { state: () => ({ count: 0 }) }) const counter = useCounter() // ❌ Wrong usage (common beginner mistake) const wrong = { count: counter.count } const { count } = storeToRefs(wrong) // count is NOT reactive — silent failure

Steps to reproduce the bug

Create any Pinia store.

Pass a plain object to storeToRefs(), for example:
storeToRefs({ count: store.count }).

Notice that no warning is shown.

The returned refs are not reactive — reactivity silently breaks.

Expected behavior

In dev mode, storeToRefs() should show a small warning when the argument
is clearly not a Pinia store (missing $id and not reactive).

This helps beginners quickly identify a common misuse

Actual behavior

storeToRefs() accepts plain objects without warning.

This causes confusing bugs because the returned refs do not update
and appear "stuck", with no indication of the mistake.

Additional information

Proposal:

Add a small dev-only check inside storeToRefs():

If the input has no $id

And is not a ref

And is not reactive

Then show a simple warning message in DEV mode.

This is 100% backward compatible and has no impact on production.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions