import type { RouteParams, RouteParamsRaw, RouteRecordRaw } from '.'
-import type { JoinPath, ParamsFromPath, ParamsRawFromPath } from './paths'
+import type { _JoinPath, ParamsFromPath, ParamsRawFromPath } from './paths'
export type RouteNamedMap<
Routes extends Readonly<RouteRecordRaw[]>,
? {
[N in Name]: {
// name: N
- params: ParamsFromPath<JoinPath<Prefix, Path>>
+ params: ParamsFromPath<_JoinPath<Prefix, Path>>
// TODO: ParamsRawFromPath
- paramsRaw: ParamsRawFromPath<JoinPath<Prefix, Path>>
- path: JoinPath<Prefix, Path>
+ paramsRaw: ParamsRawFromPath<_JoinPath<Prefix, Path>>
+ path: _JoinPath<Prefix, Path>
}
}
: {
}) &
// Recurse children
(Children extends Readonly<RouteRecordRaw[]>
- ? RouteNamedMap<Children, JoinPath<Prefix, Path>>
+ ? RouteNamedMap<Children, _JoinPath<Prefix, Path>>
: {
// NO_CHILDREN: 1
})
export type RouteNamedMapGeneric = Record<
string | symbol | number,
- // TODO: use RouteParams, RouteParamRaw
{
params: RouteParams
paramsRaw: RouteParamsRaw
? _ParamValueZeroOrOne<isRaw>
: never
+/**
+ * Utility type for raw and non raw params like :id+
+ *
+ * @internal
+ */
export type _ParamValueOneOrMore<isRaw extends boolean> = true extends isRaw
? readonly [string | number, ...(string | number)[]]
: readonly [string, ...string[]]
+/**
+ * Utility type for raw and non raw params like :id*
+ *
+ * @internal
+ */
export type _ParamValueZeroOrMore<isRaw extends boolean> = true extends isRaw
? readonly (string | number)[] | undefined | null
: readonly string[] | undefined | null
+/**
+ * Utility type for raw and non raw params like :id?
+ *
+ * @internal
+ */
export type _ParamValueZeroOrOne<isRaw extends boolean> = true extends isRaw
? RouteParamValueRaw
: string
+/**
+ * Utility type for raw and non raw params like :id
+ *
+ * @internal
+ */
export type _ParamValue<isRaw extends boolean> = true extends isRaw
? string | number
: string
: S
/**
- * Join an array of param values
+ * Join an array of param values for repeated params
*
* @internal
*/
? ''
: V extends string
? V
- : `oops`
+ : never
/**
* Possible values for a Modifier.
? readonly PathParserParamKey[] // Generic version
: _ExtractPathParamKeys<_RemoveRegexpFromParam<P>>
-export type JoinPath<
+/**
+ * Joins a prefix and a path putting a `/` between them when necessary
+ *
+ * @internal
+ */
+export type _JoinPath<
Prefix extends string,
Path extends string
> = Path extends `/${string}`