Skip to content

Commit

Permalink
fix: make 2nd argument(routeDefinition) optional
Browse files Browse the repository at this point in the history
Issue: #10
  • Loading branch information
mori5321 committed Jan 7, 2021
1 parent e01be24 commit 1d9695c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/builder/PathRouteBuilder/PathRouteBuilder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,22 @@ describe("PathRouteBuilder", () => {
state: null,
});
});
it("any works without routeDefinition(2nd argument)", () => {
const res = PathRouteBuilder.init<string>().any("id");
const subRoutes = res.anyRoute
.attach(PathRouteBuilder.init())
.routes({
hoge: {
action: () => "sub",
},
})
.getRoutes();

expect(getRouteRecordLocation(subRoutes.hoge, { id: "wow" })).toEqual({
pathname: "/wow/hoge",
state: null,
});
});
});

describe("exact route", () => {
Expand Down
4 changes: 2 additions & 2 deletions src/builder/PathRouteBuilder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export class PathRouteBuilder<
>
>(
key: Key,
routeDefinition: RD
routeDefinition?: RD
): PathRouteBuilder<
ActionResult,
Defs,
Expand Down Expand Up @@ -286,7 +286,7 @@ export class PathRouteBuilder<
// TypeScript requires this `as` but this should be true because Key extends string.
key as Extract<Key, string>,
isString,
routeDefinition.action
routeDefinition?.action
),
};
return result;
Expand Down

0 comments on commit 1d9695c

Please sign in to comment.