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
See https://www.typescriptlang.org/play?ssl=9&ssc=17&pln=1&pc=1#code/JYWwDg9gTgLgBAbzgWQgYwNYFMAmAaFdDAgN2DgF84AzKCEOAIjJiwGcZGBuAKB7QgA7DnBABGAFyFMAHgDaAXVIRgOAHxwAvHDIA6aoIAUBgJS9xukEQDCAGywBDKIbNwA9G7iCIcYGzYArlh8AsLwIABMUqiYuDIwAJ5gWBDUNIIa2noGxoJmPJGWNvZOLlzungAKdMmwCXAA5FaYdo5QDXA4EOxeEPBYAB5+8EJwicmNMdg4Mi5aGiQq6g26fNQBgmgwwKM5JogUQA
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.4
Used Package Manager
npm
Validations
Describe the bug
I'm trying to use the
Mockedutility type from thevitestpackage, but when I try to invoke.mockClear()on the result, TypeScript claims that the property does not exist. In contrast, theMockutility type does not have the same issue.Reproduction
See https://www.typescriptlang.org/play?ssl=9&ssc=17&pln=1&pc=1#code/JYWwDg9gTgLgBAbzgWQgYwNYFMAmAaFdDAgN2DgF84AzKCEOAIjJiwGcZGBuAKB7QgA7DnBABGAFyFMAHgDaAXVIRgOAHxwAvHDIA6aoIAUBgJS9xukEQDCAGywBDKIbNwA9G7iCIcYGzYArlh8AsLwIABMUqiYuDIwAJ5gWBDUNIIa2noGxoJmPJGWNvZOLlzungAKdMmwCXAA5FaYdo5QDXA4EOxeEPBYAB5+8EJwicmNMdg4Mi5aGiQq6g26fNQBgmgwwKM5JogUQA
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