preact-router icon indicating copy to clipboard operation
preact-router copied to clipboard

Add types to the Match function

Open tim-we opened this issue 3 years ago • 0 comments

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.

tim-we avatar Feb 26 '22 12:02 tim-we