You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{vi,SpyInstance}from'vitest'// does not compile when spying on Storage (spy inferred as never)vi.spyOn(window.localStorage,'getItem').mockReturnValue(null);vi.spyOn(Storage.prototype,'getItem').mockReturnValue(null);// whereas it properly compiles on an objectconststorage={getItem(key: string): string|null{returnnull}}vi.spyOn(storage,'getItem').mockReturnValue(null);// workaround: explicit cast(vi.spyOn(Storage.prototype,'getItem')asSpyInstance<Array<string>,string|null>).mockReturnValue(null);
Describe the bug
vi.spyOn(window.localStorage, 'getItem')
is wrongly inferred as never isntead ofSpyInstance
.Reproduction
This can be seen in the TS playground here
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: