From a1abbcb3af8575829dfa0ca7513a7dae9f8e236f Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Fri, 8 Aug 2025 22:23:49 +0200 Subject: [PATCH] refactor: leftover --- .../matchers/matcher-pattern.ts | 52 ------------------- 1 file changed, 52 deletions(-) diff --git a/packages/router/src/experimental/route-resolver/matchers/matcher-pattern.ts b/packages/router/src/experimental/route-resolver/matchers/matcher-pattern.ts index 00ce26bd..e1f21b78 100644 --- a/packages/router/src/experimental/route-resolver/matchers/matcher-pattern.ts +++ b/packages/router/src/experimental/route-resolver/matchers/matcher-pattern.ts @@ -150,12 +150,6 @@ export function defineParamParser(parser: { return parser } -interface IdFn { - (v: undefined | null): null - (v: string): string - (v: string[]): string[] -} - const PATH_PARAM_DEFAULT_GET = (value: string | string[] | null | undefined) => value ?? null export const PATH_PARAM_SINGLE_DEFAULT: Param_GetSet = {} @@ -344,52 +338,6 @@ export class MatcherPatternPathCustomParams< } } -const aaa = new MatcherPatternPathCustomParams( - /^\/profiles\/([^/]+)$/i, - { - userId: { - parser: PARAM_INTEGER, - // parser: PATH_PARAM_DEFAULT_PARSER, - }, - }, - ['profiles', 0] -) -// @ts-expect-error: not existing param -aaa.build({ a: '2' }) -// @ts-expect-error: must be a number -aaa.build({ userId: '2' }) -aaa.build({ userId: 2 }) -// @ts-expect-error: not existing param -aaa.match('/profiles/2')?.e -// @ts-expect-error: not existing param -aaa.match('/profiles/2').e -aaa.match('/profiles/2').userId.toFixed(2) - -// Factory function for better type inference -export function createMatcherPatternPathCustomParams< - TParamsOptions extends Record< - string, - MatcherPatternPathCustomParamOptions - >, ->( - re: RegExp, - params: TParamsOptions, - pathParts: Array -): MatcherPatternPathCustomParams { - return new MatcherPatternPathCustomParams(re, params, pathParts) -} - -// Now use it like this: -const aab = createMatcherPatternPathCustomParams( - /^\/profiles\/([^/]+)$/i, - { - userId: { - parser: PARAM_INTEGER, - }, - }, - ['profiles', 0] -) - /** * Matcher for dynamic paths, e.g. `/team/:id/:name`. * Supports one, one or zero, one or more and zero or more params. -- 2.47.3