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 (