ngx-route-manager
Version:
A route management library for Angular
17 lines (16 loc) • 1.3 kB
TypeScript
type ExtractParams<T extends string> = T extends `${infer _Start}:${infer Param}/${infer Rest}` ? Param | ExtractParams<Rest> : T extends `${infer _Start}:${infer Param}` ? Param : never;
type HasParams<T extends string> = ExtractParams<T> extends never ? false : true;
export type ParamsToFunction<T extends string, Q extends string> = HasParams<T> extends true ? (args: Record<ExtractParams<T>, string>, queryParams?: Partial<Record<Q, string>>) => string : (args?: undefined, queryParams?: Partial<Record<Q, string>>) => string;
export interface NgxParseUrl {
route: string[];
extras: {
queryParams: {
[k: string]: string;
};
};
}
export declare function createUrlFunction<T extends string, Q extends string>(template: T, queryParamsKeys?: Q): ParamsToFunction<T, Q>;
export type ParamsToUrlFunction<T extends string, Q extends string> = HasParams<T> extends true ? (args: Record<ExtractParams<T>, string>, queryParams?: Partial<Record<Q, string>>) => NgxParseUrl : (args?: undefined, queryParams?: Partial<Record<Q, string>>) => NgxParseUrl;
export declare function createUrlFunctionV2<T extends string, Q extends string>(template: T, queryParamsKeys?: Q): ParamsToUrlFunction<T, Q>;
export declare function parseUrl(url: string): NgxParseUrl;
export {};