From b57cb21f2d9d8637ef88638fb11a7a9d577509ee Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Fri, 6 Dec 2024 10:03:39 +0100 Subject: [PATCH] chore: comments --- .../router/src/new-route-resolver/matcher-location.ts | 7 ++++++- .../router/src/new-route-resolver/matchers/errors.ts | 11 +++++++++++ packages/router/tsconfig.json | 11 +++-------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/packages/router/src/new-route-resolver/matcher-location.ts b/packages/router/src/new-route-resolver/matcher-location.ts index bb44326b..1bfcd9a1 100644 --- a/packages/router/src/new-route-resolver/matcher-location.ts +++ b/packages/router/src/new-route-resolver/matcher-location.ts @@ -1,7 +1,9 @@ import type { LocationQueryRaw } from '../query' import type { MatcherName } from './matcher' -// the matcher can serialize and deserialize params +/** + * Generic object of params that can be passed to a matcher. + */ export type MatcherParamsFormatted = Record export interface MatcherLocationAsName { @@ -10,6 +12,9 @@ export interface MatcherLocationAsName { query?: LocationQueryRaw hash?: string + /** + * A path is ignored if `name` is provided. + */ path?: undefined } diff --git a/packages/router/src/new-route-resolver/matchers/errors.ts b/packages/router/src/new-route-resolver/matchers/errors.ts index 51c5574a..4ad69cc4 100644 --- a/packages/router/src/new-route-resolver/matchers/errors.ts +++ b/packages/router/src/new-route-resolver/matchers/errors.ts @@ -1,9 +1,20 @@ +/** + * NOTE: for these classes to keep the same code we need to tell TS with `"useDefineForClassFields": true` in the `tsconfig.json` + */ + +/** + * Error throw when a matcher miss + */ export class MatchMiss extends Error { name = 'MatchMiss' } +// NOTE: not sure about having a helper. Using `new MatchMiss(description?)` is good enough export const miss = () => new MatchMiss() +/** + * Error throw when a param is invalid when parsing params from path, query, or hash. + */ export class ParamInvalid extends Error { name = 'ParamInvalid' constructor(public param: string) { diff --git a/packages/router/tsconfig.json b/packages/router/tsconfig.json index 41fc6c37..318f5c65 100644 --- a/packages/router/tsconfig.json +++ b/packages/router/tsconfig.json @@ -22,19 +22,14 @@ "noImplicitReturns": true, "strict": true, "skipLibCheck": true, + "useDefineForClassFields": true, // "noUncheckedIndexedAccess": true, "experimentalDecorators": true, "resolveJsonModule": true, "esModuleInterop": true, "removeComments": false, "jsx": "preserve", - "lib": [ - "esnext", - "dom" - ], - "types": [ - "node", - "vite/client" - ] + "lib": ["esnext", "dom"], + "types": ["node", "vite/client"] } } -- 2.39.5