From 52cd4bb104238c574d4b8fde0571dce291fe7f06 Mon Sep 17 00:00:00 2001 From: Agi-Asi <206806952+Agi-Asi@users.noreply.github.com> Date: Fri, 28 Aug 2026 07:37:44 +0000 Subject: [PATCH] fix(devtools-kit): treat string value 'undefined' as a string, not null 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 #1087 --- .../devtools-kit/__tests__/component/format.test.ts | 11 +++++++++++ .../devtools-kit/src/core/component/state/format.ts | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/devtools-kit/__tests__/component/format.test.ts b/packages/devtools-kit/__tests__/component/format.test.ts index 792c3466f..1c59c8bf3 100644 --- a/packages/devtools-kit/__tests__/component/format.test.ts +++ b/packages/devtools-kit/__tests__/component/format.test.ts @@ -25,6 +25,17 @@ describe('format: displayText and rawValue can be calculated by formatInspectorS }) }) + it('type: string value "undefined" should be treated as a string, not null', () => { + // https://github.com/vuejs/devtools/issues/1087 + const value = 'undefined' + const displayText = format.formatInspectorStateValue(value) + const rawValue = format.getRaw(value).value + + expect(displayText).toBe('undefined') + expect(rawValue).toBe('undefined') + expect(format.getInspectorStateValueType(value)).toBe('string') + }) + it('type: plain object', () => { const value = { foo: 'bar' } const displayText = format.formatInspectorStateValue(value) diff --git a/packages/devtools-kit/src/core/component/state/format.ts b/packages/devtools-kit/src/core/component/state/format.ts index a6d7de1ec..b973a7142 100644 --- a/packages/devtools-kit/src/core/component/state/format.ts +++ b/packages/devtools-kit/src/core/component/state/format.ts @@ -6,7 +6,7 @@ import { escape, internalStateTokenToString, replaceStringToToken, replaceTokenT export function getInspectorStateValueType(value, raw = true) { const type = typeof value - if (value == null || value === UNDEFINED || value === 'undefined') { + if (value == null || value === UNDEFINED) { return 'null' } else if (