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

Add types to the Match function #422

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

tim-we
Copy link

@tim-we tim-we commented Feb 26, 2022

When using preact-router with TypeScript (and strict settings) you had to explicitly type the function passed as a child to the Match component like this:

<Match path="/">{({ url }: {url: string}) => <pre>{url}</pre>}</Match>

This PR overrides the type of the children property of the Match component to provide the required types. You can now use the component as intended, even in strict mode:

<Match path="/">{({ url }) => <pre>{url}</pre>}</Match>

I also removed unused imports in match/index.d.ts and test/match.tsx.

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 this pull request may close these issues.

1 participant