intlify / vue-i18n

Vue I18n for Vue 3
https://vue-i18n.intlify.dev/
MIT License
2.01k stars 320 forks source link

Key paths containing javascript built-ins are handled inconsistently #1838

Open alxndrsn opened 2 months ago

alxndrsn commented 2 months ago

Reporting a bug?

Similar to vue-i18n, using javascript builtins in key paths can have surprising results.

Ref:

Expected behavior

Keys should be handled consistently, or explicitly rejected if not supported.

Reproduction

https://github.com/intlify/vue-i18n-next/compare/master...alxndrsn:builtins?expand=1#diff-38b7f4833b6d1b2e7a9f81900841139df0e91381af1eae14cdb1f1ce432f465a

Example results:

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 18 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  packages/vue-i18n-core/test/issues.test.ts > #TODO > constructor > top-level props > with not existing key > te() > should return false
 FAIL  packages/vue-i18n-core/test/issues.test.ts > #TODO > hasOwnProperty > top-level props > with not existing key > te() > should return false
 FAIL  packages/vue-i18n-core/test/issues.test.ts > #TODO > isPrototypeOf > top-level props > with not existing key > te() > should return false
 FAIL  packages/vue-i18n-core/test/issues.test.ts > #TODO > propertyIsEnumerable > top-level props > with not existing key > te() > should return false
 FAIL  packages/vue-i18n-core/test/issues.test.ts > #TODO > toLocaleString > top-level props > with not existing key > te() > should return false
 FAIL  packages/vue-i18n-core/test/issues.test.ts > #TODO > toString > top-level props > with not existing key > te() > should return false
 FAIL  packages/vue-i18n-core/test/issues.test.ts > #TODO > valueOf > top-level props > with not existing key > te() > should return false
AssertionError: expected true to deeply equal false

- Expected
+ Received

- false
+ true

 ❯ packages/vue-i18n-core/test/issues.test.ts:1486:41
    1484|               const i18n = i18nFor({})
    1485| 
    1486|               expect(i18n.global.te(k)).toEqual(false)
       |                                         ^
    1487|             })
    1488|           })

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/18]⎯

 FAIL  packages/vue-i18n-core/test/issues.test.ts > #TODO > constructor > top-level props > with not existing key > t() > should return key
SyntaxError: Unexpected return type in composer
 ❯ Module.createCompileError packages/message-compiler/src/errors.ts:92:17
     90|     ? format((messages || errorMessages)[code] || '', ...(args || []))
     91|     : code
     92|   const error = new SyntaxError(String(msg)) as CompileError
       |                 ^
     93|   error.code = code
     94|   if (loc) {
 ❯ Module.createI18nError packages/vue-i18n-core/src/errors.ts:41:10
 ❯ wrapWithDeps packages/vue-i18n-core/src/composer.ts:2282:13
 ❯ Object.t packages/vue-i18n-core/src/composer.ts:2288:12
 ❯ Object.t packages/vue-i18n-core/src/legacy.ts:1708:22
 ❯ packages/vue-i18n-core/test/issues.test.ts:1495:34

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { code: 24, domain: undefined }
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/18]⎯

 FAIL  packages/vue-i18n-core/test/issues.test.ts > #TODO > hasOwnProperty > top-level props > with existing key > t() > should return hi
TypeError: Cannot read properties of undefined (reading 'hasOwnProperty')
 ❯ hasOwnProperty node_modules/.pnpm/@vue+reactivity@3.4.26/node_modules/@vue/reactivity/dist/reactivity.cjs.js:452:14
 ❯ evaluateMessage packages/core-base/src/translate.ts:1016:20
    1014|   }
    1015| 
    1016|   const messaged = msg(msgCtx)
       |                    ^
    1017| 
    1018|   // for vue-devtools timeline event
 ❯ translate packages/core-base/src/translate.ts:757:20
 ❯ packages/vue-i18n-core/src/composer.ts:2289:26
 ❯ wrapWithDeps packages/vue-i18n-core/src/composer.ts:2227:13
 ❯ Object.t packages/vue-i18n-core/src/composer.ts:2288:12
 ❯ Object.t packages/vue-i18n-core/src/legacy.ts:1708:22
 ❯ packages/vue-i18n-core/test/issues.test.ts:1475:34

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[3/18]⎯

 FAIL  packages/vue-i18n-core/test/issues.test.ts > #TODO > hasOwnProperty > top-level props > with not existing key > t() > should return key
TypeError: Cannot read properties of undefined (reading 'hasOwnProperty')
 ❯ hasOwnProperty node_modules/.pnpm/@vue+reactivity@3.4.26/node_modules/@vue/reactivity/dist/reactivity.cjs.js:452:14
 ❯ evaluateMessage packages/core-base/src/translate.ts:1016:20
    1014|   }
    1015| 
    1016|   const messaged = msg(msgCtx)
       |                    ^
    1017| 
    1018|   // for vue-devtools timeline event
 ❯ translate packages/core-base/src/translate.ts:757:20
 ❯ packages/vue-i18n-core/src/composer.ts:2289:26
 ❯ wrapWithDeps packages/vue-i18n-core/src/composer.ts:2227:13
 ❯ Object.t packages/vue-i18n-core/src/composer.ts:2288:12
 ❯ Object.t packages/vue-i18n-core/src/legacy.ts:1708:22
 ❯ packages/vue-i18n-core/test/issues.test.ts:1495:34

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[4/18]⎯

 FAIL  packages/vue-i18n-core/test/issues.test.ts > #TODO > hasOwnProperty > mid-level props > with existing key > te() > should return true
AssertionError: expected false to deeply equal true

- Expected
+ Received

- true
+ false

 ❯ packages/vue-i18n-core/test/issues.test.ts:1515:41
    1513|               })
    1514| 
    1515|               expect(i18n.global.te(k)).toEqual(true)
       |                                         ^
    1516|             })
    1517|           })

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[5/18]⎯

 FAIL  packages/vue-i18n-core/test/issues.test.ts > #TODO > hasOwnProperty > mid-level props > with existing key > t() > should return hi
AssertionError: expected 'a.hasOwnProperty.c' to deeply equal 'hi'

- Expected
+ Received

- hi
+ a.hasOwnProperty.c

 ❯ packages/vue-i18n-core/test/issues.test.ts:1531:40
    1529|               })
    1530| 
    1531|               expect(i18n.global.t(k)).toEqual('hi')
       |                                        ^
    1532|             })
    1533|           })

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[6/18]⎯

 FAIL  packages/vue-i18n-core/test/issues.test.ts > #TODO > hasOwnProperty > deep props > with existing key > t() > should return hi
TypeError: Cannot read properties of undefined (reading 'hasOwnProperty')
 ❯ hasOwnProperty node_modules/.pnpm/@vue+reactivity@3.4.26/node_modules/@vue/reactivity/dist/reactivity.cjs.js:452:14
 ❯ evaluateMessage packages/core-base/src/translate.ts:1016:20
    1014|   }
    1015| 
    1016|   const messaged = msg(msgCtx)
       |                    ^
    1017| 
    1018|   // for vue-devtools timeline event
 ❯ translate packages/core-base/src/translate.ts:757:20
 ❯ packages/vue-i18n-core/src/composer.ts:2289:26
 ❯ wrapWithDeps packages/vue-i18n-core/src/composer.ts:2227:13
 ❯ Object.t packages/vue-i18n-core/src/composer.ts:2288:12
 ❯ Object.t packages/vue-i18n-core/src/legacy.ts:1708:22
 ❯ packages/vue-i18n-core/test/issues.test.ts:1585:34

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[7/18]⎯

 FAIL  packages/vue-i18n-core/test/issues.test.ts > #TODO > isPrototypeOf > top-level props > with not existing key > t() > should return key
TypeError: Cannot convert undefined or null to object
 ❯ evaluateMessage packages/core-base/src/translate.ts:1016:20
    1014|   }
    1015| 
    1016|   const messaged = msg(msgCtx)
       |                    ^
    1017| 
    1018|   // for vue-devtools timeline event
 ❯ translate packages/core-base/src/translate.ts:757:20
 ❯ packages/vue-i18n-core/src/composer.ts:2289:26
 ❯ wrapWithDeps packages/vue-i18n-core/src/composer.ts:2227:13
 ❯ Object.t packages/vue-i18n-core/src/composer.ts:2288:12
 ❯ Object.t packages/vue-i18n-core/src/legacy.ts:1708:22
 ❯ packages/vue-i18n-core/test/issues.test.ts:1495:34

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[8/18]⎯

 FAIL  packages/vue-i18n-core/test/issues.test.ts > #TODO > propertyIsEnumerable > top-level props > with not existing key > t() > should return key
TypeError: Cannot convert undefined or null to object
 ❯ evaluateMessage packages/core-base/src/translate.ts:1016:20
    1014|   }
    1015| 
    1016|   const messaged = msg(msgCtx)
       |                    ^
    1017| 
    1018|   // for vue-devtools timeline event
 ❯ translate packages/core-base/src/translate.ts:757:20
 ❯ packages/vue-i18n-core/src/composer.ts:2289:26
 ❯ wrapWithDeps packages/vue-i18n-core/src/composer.ts:2227:13
 ❯ Object.t packages/vue-i18n-core/src/composer.ts:2288:12
 ❯ Object.t packages/vue-i18n-core/src/legacy.ts:1708:22
 ❯ packages/vue-i18n-core/test/issues.test.ts:1495:34

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[9/18]⎯

 FAIL  packages/vue-i18n-core/test/issues.test.ts > #TODO > toLocaleString > top-level props > with not existing key > t() > should return key
TypeError: Object.prototype.toLocaleString called on null or undefined
 ❯ evaluateMessage packages/core-base/src/translate.ts:1016:20
    1014|   }
    1015| 
    1016|   const messaged = msg(msgCtx)
       |                    ^
    1017| 
    1018|   // for vue-devtools timeline event
 ❯ translate packages/core-base/src/translate.ts:757:20
 ❯ packages/vue-i18n-core/src/composer.ts:2289:26
 ❯ wrapWithDeps packages/vue-i18n-core/src/composer.ts:2227:13
 ❯ Object.t packages/vue-i18n-core/src/composer.ts:2288:12
 ❯ Object.t packages/vue-i18n-core/src/legacy.ts:1708:22
 ❯ packages/vue-i18n-core/test/issues.test.ts:1495:34

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[10/18]⎯

 FAIL  packages/vue-i18n-core/test/issues.test.ts > #TODO > toString > top-level props > with not existing key > t() > should return key
AssertionError: expected '[object Undefined]' to deeply equal 'toString'

- Expected
+ Received

- toString
+ [object Undefined]

 ❯ packages/vue-i18n-core/test/issues.test.ts:1495:40
    1493|               const i18n = i18nFor({})
    1494| 
    1495|               expect(i18n.global.t(k)).toEqual(k)
       |                                        ^
    1496|             })
    1497|           })

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[11/18]⎯

 FAIL  packages/vue-i18n-core/test/issues.test.ts > #TODO > valueOf > top-level props > with not existing key > t() > should return key
TypeError: Cannot convert undefined or null to object
 ❯ evaluateMessage packages/core-base/src/translate.ts:1016:20
    1014|   }
    1015| 
    1016|   const messaged = msg(msgCtx)
       |                    ^
    1017| 
    1018|   // for vue-devtools timeline event
 ❯ translate packages/core-base/src/translate.ts:757:20
 ❯ packages/vue-i18n-core/src/composer.ts:2289:26
 ❯ wrapWithDeps packages/vue-i18n-core/src/composer.ts:2227:13
 ❯ Object.t packages/vue-i18n-core/src/composer.ts:2288:12
 ❯ Object.t packages/vue-i18n-core/src/legacy.ts:1708:22
 ❯ packages/vue-i18n-core/test/issues.test.ts:1495:34

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[12/18]⎯

 Test Files  1 failed | 51 passed (52)
      Tests  18 failed | 707 passed | 35 skipped | 37 todo (797)
   Start at  14:26:57
   Duration  19.59s (transform 2.26s, setup 11ms, collect 10.52s, tests 3.87s, environment 16.22s, prepare 10.85s)

 ELIFECYCLE  Command failed with exit code 1.
 ELIFECYCLE  Command failed with exit code 1.
ERROR: "test:cover" exited with 1.
 ELIFECYCLE  Test failed. See above for more details.

System Info

N/A

Screenshot

No response

Additional context

No response

Validations

kazupon commented 2 months ago

related #1711

alxndrsn commented 2 months ago

Happy to provide a fix if the correct behaviour is known :slightly_smiling_face:

alxndrsn commented 2 months ago

Current failures:

 constructor > deep props > with existing absolute key > te() > should return true
 constructor > mid-level props > with existing absolute key > te() > should return true
 constructor > single-level props > with not existing key > t() > should return key
 constructor > single-level props > with not existing key > te() > should return false
 constructor > top-level props > with existing absolute key > te() > should return true
 control > deep props > with existing absolute key > te() > should return true
 control > mid-level props > with existing absolute key > te() > should return true
 control > top-level props > with existing absolute key > te() > should return true
 hasOwnProperty > deep props > with existing absolute key > te() > should return true
 hasOwnProperty > deep props > with existing nested key > t() > should return hi
 hasOwnProperty > mid-level props > with existing absolute key > te() > should return true
 hasOwnProperty > mid-level props > with existing nested key > t() > should return hi
 hasOwnProperty > mid-level props > with existing nested key > te() > should return true
 hasOwnProperty > single-level props > with existing key > t() > should return hi
 hasOwnProperty > single-level props > with not existing key > t() > should return key
 hasOwnProperty > single-level props > with not existing key > te() > should return false
 hasOwnProperty > top-level props > with existing absolute key > te() > should return true
 hasOwnProperty > top-level props > with existing nested key > t() > should return hi
 hasOwnProperty > top-level props > with existing nested key > te() > should return true
 isPrototypeOf > deep props > with existing absolute key > te() > should return true
 isPrototypeOf > mid-level props > with existing absolute key > te() > should return true
 isPrototypeOf > single-level props > with not existing key > t() > should return key
 isPrototypeOf > single-level props > with not existing key > te() > should return false
 isPrototypeOf > top-level props > with existing absolute key > te() > should return true
 link > deep props > with existing absolute key > te() > should return true
 link > mid-level props > with existing absolute key > te() > should return true
 link > top-level props > with existing absolute key > te() > should return true
 propertyIsEnumerable > deep props > with existing absolute key > te() > should return true
 propertyIsEnumerable > mid-level props > with existing absolute key > te() > should return true
 propertyIsEnumerable > single-level props > with not existing key > t() > should return key
 propertyIsEnumerable > single-level props > with not existing key > te() > should return false
 propertyIsEnumerable > top-level props > with existing absolute key > te() > should return true
 __proto__ > deep props > with existing absolute key > te() > should return true
 __proto__ > mid-level props > with existing absolute key > te() > should return true
 __proto__ > top-level props > with existing absolute key > te() > should return true
 toLocaleString > deep props > with existing absolute key > te() > should return true
 toLocaleString > mid-level props > with existing absolute key > te() > should return true
 toLocaleString > single-level props > with not existing key > t() > should return key
 toLocaleString > single-level props > with not existing key > te() > should return false
 toLocaleString > top-level props > with existing absolute key > te() > should return true
 toString > deep props > with existing absolute key > te() > should return true
 toString > mid-level props > with existing absolute key > te() > should return true
 toString > single-level props > with not existing key > t() > should return key
 toString > single-level props > with not existing key > te() > should return false
 toString > top-level props > with existing absolute key > te() > should return true
 valueOf > deep props > with existing absolute key > te() > should return true
 valueOf > mid-level props > with existing absolute key > te() > should return true
 valueOf > single-level props > with not existing key > t() > should return key
 valueOf > single-level props > with not existing key > te() > should return false
 valueOf > top-level props > with existing absolute key > te() > should return true