···217217When `partial` is `true` it will expect a `Partial<T>` as a return value. By default, this will only make TypeScript believe that the first level values are mocked. You can pass down `{ deep: true }` as a second argument to tell TypeScript that the whole object is mocked, if it actually is.
218218219219```ts
220220-import example from './example.js'
220220+// example.ts
221221+export function add(x: number, y: number): number {
222222+ return x + y
223223+}
221224222222-vi.mock('./example.js')
225225+export function fetchSomething(): Promise<Response> {
226226+ return fetch('https://vitest.dev/')
227227+}
228228+```
229229+230230+```ts
231231+// example.test.ts
232232+import * as example from './example'
233233+234234+vi.mock('./example')
223235224236test('1 + 1 equals 10', async () => {
225225- vi.mocked(example.calc).mockReturnValue(10)
226226- expect(example.calc(1, '+', 1)).toBe(10)
237237+ vi.mocked(example.add).mockReturnValue(10)
238238+ expect(example.add(1, 1)).toBe(10)
239239+})
240240+241241+test('mock return value with only partially correct typing', async () => {
242242+ vi.mocked(example.fetchSomething).mockResolvedValue(new Response('hello'))
243243+ vi.mocked(example.fetchSomething, { partial: true }).mockResolvedValue({ ok: false })
244244+ // vi.mocked(example.someFn).mockResolvedValue({ ok: false }) // this is a type error
227245})
228246```
229247