make id required in createRouteRef config

Signed-off-by: Colton Padden <colton.padden@fastmail.com>
This commit is contained in:
Colton Padden
2021-12-20 13:20:31 -05:00
parent cb278fa3ad
commit 2928eeda77
2 changed files with 3 additions and 7 deletions
+1 -1
View File
@@ -357,7 +357,7 @@ export function createRouteRef<
},
ParamKey extends string = never,
>(config: {
id?: string;
id: string;
params?: ParamKey[];
}): RouteRef<OptionalParams<Params>>;
@@ -62,16 +62,12 @@ export function createRouteRef<
ParamKey extends string = never,
>(config: {
/** The id of the route ref, used to identify it when printed */
id?: string;
id: string;
/** A list of parameter names that the path that this route ref is bound to must contain */
params?: ParamKey[];
}): RouteRef<OptionalParams<Params>> {
const id = config.id;
if (!id) {
throw new Error('RouteRef must be provided a non-empty id');
}
return new RouteRefImpl(
id,
config.id,
(config.params ?? []) as ParamKeys<OptionalParams<Params>>,
);
}