Skip to content

fix(devtools-kit): treat string value 'undefined' as a string, not null - #2

Closed
arena-ai-coding-agent[bot] wants to merge 1 commit into
mainfrom
fix/issue-1087-string-undefined
Closed

fix(devtools-kit): treat string value 'undefined' as a string, not null#2
arena-ai-coding-agent[bot] wants to merge 1 commit into
mainfrom
fix/issue-1087-string-undefined

Conversation

@arena-ai-coding-agent

Copy link
Copy Markdown

Summary

When a state value (e.g. a Pinia store state field) contains the string "undefined", Vue DevTools renders it as the actual undefined value instead of a string:

const useTestStore = defineStore('test', {
  state: () => ({ value: 'undefined' }),
})

Cause

getInspectorStateValueType() in packages/devtools-kit/src/core/component/state/format.ts contained a literal string check:

if (value == null || value === UNDEFINED || value === 'undefined') {
  return 'null'
}

A real undefined value is represented internally by the UNDEFINED sentinel token (__vue_devtool_undefined__), so the value === 'undefined' branch was unnecessary and wrongly flagged the legitimate string 'undefined' as the null/undefined type. The UI then styles it with the null-state-type class (no quotes, null styling), making it look like the real undefined.

Fix

Remove the erroneous value === 'undefined' check. Actual undefined values are still correctly handled by value == null and value === UNDEFINED.

Tests

Added a regression test that asserts the string 'undefined' is classified as string and renders as 'undefined'. The full suite passes (86 tests) along with type-check, lint, and build.

Closes vuejs#1087

When a state value (e.g. a Pinia store state) contains the string
'undefined', getInspectorStateValueType wrongly classified it as the
null/undefined type because of a literal string check. This caused the
value to be rendered as the actual undefined value instead of a string.

Remove the erroneous check for the literal 'undefined' string. Real
undefined values are represented by the UNDEFINED sentinel token, so they
are still handled correctly.

Closes vuejs#1087
@arena-ai-coding-agent

Copy link
Copy Markdown
Author

Closing this PR because issue vuejs#1087 is already addressed by the existing upstream PR vuejs#1088. This change would be a duplicate.

@arena-ai-coding-agent
arena-ai-coding-agent Bot deleted the fix/issue-1087-string-undefined branch August 28, 2026 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect string highlighting for "undefined" in Pinia state

1 participant