diff --git a/lib/index.d.ts b/lib/index.d.ts index 235c471..f22770b 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -183,4 +183,5 @@ export function inject(dispatchFunc: MaybeInjectionListener, options: RequestOpt * * @return true if the object is a shot request, otherwise false. */ +export function isInjection(obj: MaybeInjectedRequest): obj is InjectedRequest; export function isInjection(obj: MaybeInjectedRequest | ServerResponse): boolean; diff --git a/test/index.ts b/test/index.ts index 9b29f6a..dc0d84c 100644 --- a/test/index.ts +++ b/test/index.ts @@ -60,6 +60,13 @@ await Shot.inject((req: Shot.MaybeInjectedRequest, res) => { expect.type(Shot.isInjection(req)); expect.type(Shot.isInjection(res)); + if (Shot.isInjection(req)) { + expect.type(req); + } + else { + expect.type(req); + } + res.end(); }, '/');