Skip to content

Commit

Permalink
fix: optional params may be undefined (4Catalyzer#1057)
Browse files Browse the repository at this point in the history
  • Loading branch information
steinybot committed Jan 31, 2024
1 parent 2ce1eb6 commit ebde858
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/typeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ type Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
// RESOLVE_MATCH: '@@found/RESOLVE_MATCH';
// };

export type Params = Record<string, string>;
export type Params = Record<string, string | undefined>;

export type ParamsDescriptor = Record<
string,
string | number | boolean | Record<string, unknown>
string | number | boolean | Record<string, unknown> | undefined
>;

// These need to be interfaces to avoid circular reference issues.
Expand Down
3 changes: 1 addition & 2 deletions test/Matcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit ebde858

Please sign in to comment.