Skip to content

Typing regression on "useI18n()": spyOn return "never" type #1562

@pinguet62

Description

@pinguet62

Reporting a bug?

After upgrade from 9.3.0-beta.27, the mock of useI18n() doesn't work:

import * as vueI18n from 'vue-i18n'

vi.spyOn(vueI18n, 'useI18n').mockReturnValue({})

throws
Property 'mockReturnValue' does not exist on type 'never'.

Expected behavior

No error :)

Reproduction

  1. Create TypeScript project
  2. npm install vue-i118n
  3. Add a simple test
    import { vi } from 'vitest'
    import * as vueI18n from 'vue-i18n'
    vi.spyOn(vueI18n, 'useI18n').mockReturnValue({})
  4. npm run type-check

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12800H
    Memory: 10.91 GB / 31.69 GB
  Binaries:
    Node: 20.0.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 9.8.1 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.5.0 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Edge: Spartan (44.22621.2134.0), Chromium (117.0.2045.36)
    Internet Explorer: 11.0.22621.1

Screenshot

No response

Additional context

Seems be a regression in #1309 7ebb0e4#diff-90783ef144f3a897c890355ff61bd08a99bbd36764128426b6f899a72e766f2eR803

Reverting line to previous version NonNullable<Options['locale']> seems fix the problem.
Like the test:type checks are still OK, probably the current typing is too strict? 🤔

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions