From ebde85811652d6041289b9ae6bc8ffaaf08598c9 Mon Sep 17 00:00:00 2001 From: Jason Pickens Date: Thu, 1 Feb 2024 12:18:55 +1300 Subject: [PATCH] fix: optional params may be undefined (#1057) --- src/typeUtils.ts | 4 ++-- test/Matcher.test.ts | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/typeUtils.ts b/src/typeUtils.ts index b0da5dd7..66170644 100644 --- a/src/typeUtils.ts +++ b/src/typeUtils.ts @@ -39,11 +39,11 @@ type Omit = Pick>; // RESOLVE_MATCH: '@@found/RESOLVE_MATCH'; // }; -export type Params = Record; +export type Params = Record; export type ParamsDescriptor = Record< string, - string | number | boolean | Record + string | number | boolean | Record | undefined >; // These need to be interfaces to avoid circular reference issues. diff --git a/test/Matcher.test.ts b/test/Matcher.test.ts index a887e06c..94c97763 100644 --- a/test/Matcher.test.ts +++ b/test/Matcher.test.ts @@ -223,8 +223,7 @@ describe('Matcher', () => { const missingMatch = matcher.match({ pathname: '/a' }); if (missingMatch != null && 0 in missingMatch.params) { - // FIXME: This type is wrong. It should be string | undefined. - const param: string = missingMatch.params[0]; + const param: string | undefined = missingMatch.params[0]; expect(param).toBeUndefined(); }