Skip to content

useMatches and Typescript #9534

Closed Answered by brophdawg11
bnabet asked this question in Q&A
Nov 1, 2022 · 4 comments · 1 reply
Discussion options

You must be logged in to vote

useMatches does not return RouteObject[], but since they share some properties TS is allowing you to incorrectly define the type that way. A "match" in this case is a mixtures of a matched route and the result of the routes loader function, so just remove : RouteObject[] and TS should be happy:

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@brophdawg11
Comment options

Answer selected by MichaelDeBoey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants