-
-
Couldn't load subscription status.
- Fork 1.5k
Open
Labels
Description
Describe the bug
Consider the following TS class:
export class MyClass {
private innerProperty = () => 'inner';
public outerProperty = () => 'outer';
}When trying to stub it, Mocked complains if the private property is omitted:
const myClass: Mocked<MyClass> = { outerProperty: vi.fn() };
// Type '{ outerProperty: Mock<() => string>; }' is not assignable to type 'Mocked<MyClass>'.
// Property 'innerProperty' is missing in type '{ outerProperty: Mock<() => string>; }' but required in type 'MyClass'.I would expect the mock to be OK if only the public properties are provided.
Reproduction
System Info
System:
OS: macOS 15.6.1
CPU: (10) arm64 Apple M1 Max
Memory: 9.06 GB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.18.0 - /Users/cedric/.volta/tools/image/node/22.18.0/bin/node
Yarn: 1.22.22 - /Users/cedric/.volta/tools/image/yarn/1.22.22/bin/yarn
npm: 10.9.0 - /Users/cedric/.volta/tools/image/npm/10.9.0/bin/npm
pnpm: 10.19.0 - /Users/cedric/.volta/tools/image/node/22.18.0/bin/pnpm
Browsers:
Chrome: 141.0.7390.123
Firefox: 142.0
Safari: 18.6
npmPackages:
@vitest/browser-playwright: 4.0.2 => 4.0.2
@vitest/coverage-v8: 4.0.2 => 4.0.2
vitest: 4.0.2 => 4.0.2Used 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.