diff --git a/src/index.ts b/src/index.ts
index ef0a2a5..dc0fbea 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -2,4 +2,4 @@ export * from './spy'
export * from './spyOn'
export * from './restoreAll'
export { createInternalSpy, spies, getInternalState } from './internal'
-export type { Spy, SpyImpl } from './internal'
+export type { Spy, SpyImpl, SpyInternal, SpyInternalImpl } from './internal'
diff --git a/src/internal.ts b/src/internal.ts
index 8bed480..8355d81 100644
--- a/src/internal.ts
+++ b/src/internal.ts
@@ -1,6 +1,11 @@
import { assert, define, defineValue, isPromise, isType } from './utils'
import { S } from './constants'
+interface GetState {
+ (spy: SpyInternalImpl): SpyInternalImplState
+ (spy: SpyInternal): SpyInternalState
+}
+
export let spies = new Set()
let reset = (state: SpyInternalState) => {
@@ -13,8 +18,8 @@ let defineState = (spy: SpyInternal) => {
define(spy, S, { value: { reset: () => reset(spy[S]) } })
return spy[S]
}
-export let getInternalState = (spy: SpyInternal) => {
- return spy[S] || defineState(spy)
+export let getInternalState: GetState = (spy) => {
+ return (spy[S] || defineState(spy)) as any
}
type ReturnError = ['error', any]
diff --git a/src/spyOn.ts b/src/spyOn.ts
index 432a758..130ee67 100644
--- a/src/spyOn.ts
+++ b/src/spyOn.ts
@@ -23,7 +23,7 @@ type Constructors = {
let getDescriptor = (obj: any, method: string | symbol | number) =>
Object.getOwnPropertyDescriptor(obj, method)
-export function internalSpyOn(
+export function internalSpyOn(
obj: T,
methodName: K | { getter: K } | { setter: K },
mock?: Procedure
diff --git a/src/utils.ts b/src/utils.ts
index 329587f..c1b6928 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -1,4 +1,4 @@
-export function assert(condition: any, message: string) {
+export function assert(condition: any, message: string): asserts condition {
if (!condition) {
throw new Error(message)
}