Skip to content

Commit

Permalink
child matches may be undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
pcattori committed Dec 2, 2024
1 parent 748e9eb commit 463174f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions integration/typegen-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,10 @@ test.describe("typegen", () => {
type Test3 = Expect<Equal<typeof current.data, { current: number }>>
const child1 = matches[4]
type Test4 = Expect<Equal<typeof child1.data, unknown>>
type Test4a = Expect<undefined extends typeof child1 ? true : false>
if (child1) {
type Test4b = Expect<Equal<typeof child1.data, unknown>>
}
return []
}
Expand All @@ -312,7 +315,10 @@ test.describe("typegen", () => {
type Test3 = Expect<Equal<typeof current.data, { current: number }>>
const child1 = matches[4]
type Test4 = Expect<Equal<typeof child1.data, unknown>>
type Test4a = Expect<undefined extends typeof child1 ? true : false>
if (child1) {
type Test4b = Expect<Equal<typeof child1.data, unknown>>
}
}
`,
});
Expand Down
4 changes: 2 additions & 2 deletions packages/react-router/lib/types/route-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type MetaMatch<T extends RouteInfo> = Pretty<
type MetaMatches<T extends RouteInfo[]> =
T extends [infer F extends RouteInfo, ...infer R extends RouteInfo[]]
? [MetaMatch<F>, ...MetaMatches<R>]
: MetaMatch<RouteInfo>[];
: Array<MetaMatch<RouteInfo> | undefined>;

export type CreateMetaArgs<T extends RouteInfo> = {
location: Location;
Expand Down Expand Up @@ -149,7 +149,7 @@ type Match<T extends RouteInfo> = Pretty<
type Matches<T extends RouteInfo[]> =
T extends [infer F extends RouteInfo, ...infer R extends RouteInfo[]]
? [Match<F>, ...Matches<R>]
: Match<RouteInfo>[];
: Array<Match<RouteInfo> | undefined>;

export type CreateComponentProps<T extends RouteInfo> = {
params: T["params"];
Expand Down

0 comments on commit 463174f

Please sign in to comment.