-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Describe the bug
I'm trying to use the Mocked utility type from the vitest package, but when I try to invoke .mockClear() on the result, TypeScript claims that the property does not exist. In contrast, the Mock utility type does not have the same issue.
Reproduction
import { Mocked, Mock, vi } from "vitest";
const m1: Mock<[], void> = vi.fn(fn);
m1.mockClear(); // no issue
const m2: Mocked<typeof fn> = vi.fn(fn);
m2.mockClear(); // Property 'mockClear' does not exist on type 'Mocked<() => void>'.
function fn() {}System Info
System:
OS: macOS 14.1.2
CPU: (10) arm64 Apple M1 Pro
Memory: 156.53 MB / 32.00 GB
Shell: 5.9 - /opt/homebrew/bin/zsh
Binaries:
Node: 21.4.0 - /opt/homebrew/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 10.2.4 - /opt/homebrew/bin/npm
pnpm: 8.10.3 - /opt/homebrew/bin/pnpm
Browsers:
Chrome: 120.0.6099.71
Edge: 120.0.2210.61
Safari: 17.1.2
npmPackages:
@vitejs/plugin-react: ^4.2.1 => 4.2.1
vitest: ^1.0.4 => 1.0.4Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Type
Projects
Status
No status