Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultParams type doesn't count with optional parameters #214

Closed
Poky85 opened this issue Sep 19, 2021 · 2 comments · Fixed by #262
Closed

DefaultParams type doesn't count with optional parameters #214

Poky85 opened this issue Sep 19, 2021 · 2 comments · Fixed by #262

Comments

@Poky85
Copy link

Poky85 commented Sep 19, 2021

Wouter export types:

export interface DefaultParams {
  [paramName: string]: string;
}
export type Params<T extends DefaultParams = DefaultParams> = T;

Let's use dynamic segment in the path, eg:

<Route path="/:foo/:bar?">
  {(params) => {
    
  }}
</Route>;

...and match the route against path /hello. Then matcher returns params as following: { foo: hello, bar: undefined }. But those params doesn't comply with DefaultParams definition. So I think it should be:

export interface DefaultParams {
  [paramName: string]: string | undefined;
}
@molefrog
Copy link
Owner

Hey @itsMapleLeaf @cbbfcd could you take a look at the proposed change?

@cbbfcd
Copy link
Contributor

cbbfcd commented Sep 22, 2021

@Poky85 may be resolved by #211 .

and @itsMapleLeaf, It looks like we need to add some test cases 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants