diff --git a/src/resolver/resolver.ts b/src/resolver/resolver.ts index 715fb275..10495b94 100644 --- a/src/resolver/resolver.ts +++ b/src/resolver/resolver.ts @@ -36,7 +36,14 @@ function isDescendantRoute( } function isRouteContext(value: unknown): value is RouteContext { - return !!value && typeof value === 'object' && 'result' in value; + return ( + !!value && + typeof value === 'object' && + 'next' in value && + 'params' in value && + 'result' in value && + 'route' in value + ); } export interface ResolutionErrorOptions extends ErrorOptions { diff --git a/test/resolver/resolver.spec.ts b/test/resolver/resolver.spec.ts index b6dc0fea..ee2e7455 100644 --- a/test/resolver/resolver.spec.ts +++ b/test/resolver/resolver.spec.ts @@ -773,6 +773,20 @@ describe('Resolver', () => { expect(action.calledOnce).to.be.true; expect(middleware.calledOnce).to.be.true; }); + + it('should match routes with object result', async () => { + const resolver = new Resolver([ + { + action() { + return { result: 'ok' }; + }, + path: '/match', + }, + ]); + + const context = await resolver.resolve('/match'); + expect(context).to.have.property('result').that.deep.equals({ result: 'ok' }); + }); }); // describe('Resolver.__createUrl(path, base) hook', () => {