Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
4 tasks done
pinguet62 opened this issue Sep 21, 2023 · 3 comments · Fixed by #1815
Closed
4 tasks done

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

pinguet62 opened this issue Sep 21, 2023 · 3 comments · Fixed by #1815
Labels
Status: Need More Info Lacks enough info to make progress

Comments

@pinguet62
Copy link
Contributor

pinguet62 commented Sep 21, 2023

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

@pinguet62 pinguet62 added the Status: Review Needed Request for review comments label Sep 21, 2023
@kazupon kazupon added the Status: Need More Info Lacks enough info to make progress label Oct 16, 2023 — with Volta.net
@github-actions
Copy link

Would you be able to provide a reproduction 🙏

More info

Why do I need to provide a reproduction?

Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.

What will happen?

If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect.

If Status: Need More Info labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.

How can I create a reproduction?

We have a couple of templates for starting with a minimal reproduction:

👉 Reproduction mininal starter
👉 Reproduction starter with unpluguin-vue-i18n

A public GitHub repository is also perfect. 👌

Please ensure that the reproduction is as minimal as possible.

You might also find these other articles interesting and/or helpful:

@kazupon kazupon removed the Status: Review Needed Request for review comments label Oct 16, 2023 — with Volta.net
@pinguet62
Copy link
Contributor Author

pinguet62 commented Oct 27, 2023

I created a repo with minimal configuration
ℹ️ 1 commit == 1 CLI command

git clone git@github.com:pinguet62/vue-i18n--typing-regression.git
cd vue-i18n--typing-regression
npm ci
npm run type-check
> vue-i18n--typing-regression@0.0.0 type-check
> vue-tsc --noEmit -p tsconfig.vitest.json --composite false

src/sample.spec.ts:8:38 - error TS2339: Property 'mockReturnValue' does not exist on type 'never'.

8         vi.spyOn(vueI18n, 'useI18n').mockReturnValue({
                                       ~~~~~~~~~~~~~~~


Found 1 error in src/sample.spec.ts:8


Process finished with exit code 2

@pinguet62
Copy link
Contributor Author

🖖 Any news?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Need More Info Lacks enough info to make progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants