Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(typedRoutes): fixed StaticRoutes and DynamicRoutes being empty causing invalid syntax #46620

Merged
merged 6 commits into from
Mar 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ function createRouteDefinitions(
}
}

const fallback = !edgeRoutes.length && !nodeRoutes.length ? 'string' : ''
const routes = [...edgeRoutes, ...nodeRoutes, ...extraRoutes]

// By exposing the static route types separately as string literals,
Expand Down Expand Up @@ -267,10 +266,12 @@ declare namespace __next_route_internal_types__ {
type OptionalCatchAllSlug<S extends string> =
S extends \`\${string}\${SearchOrHash}\` ? never : S

type StaticRoutes = ${staticRouteTypes}
type DynamicRoutes<T extends string = string> = ${dynamicRouteTypes}
type StaticRoutes = ${staticRouteTypes || 'string'}
type DynamicRoutes<T extends string = string> = ${
dynamicRouteTypes || 'string'
}

type RouteImpl<T> = ${fallback}
type RouteImpl<T> =
| StaticRoutes
| \`\${StaticRoutes}\${Suffix}\`
| (T extends \`\${DynamicRoutes<infer _>}\${Suffix}\` ? T : never)
Expand Down