Help migrating from ts-toolbelt #99
Unanswered
kevinwolfcr
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So far I have been using
ts-toolbelt
to create a function that receives a raw Next.js route path, and returns the appropriate prop types that route will use. So, it goes through all the route segments and:[mySegment]
to{ mySegment: string }
[...mySegment]
to{ mySegment: [string, ...string[]] }
[[...mySegment]]
to{ mySegment?: [string, ...string[]] }
Then, I loop through all the segments, get the props for each segment, and join all the props from the segments, using the following function (live repro: https://tsplay.dev/N5xKVw):
Having this output:
I would love to practice more functional programming, and give this library a chance, is there any recommended way to do it? So far I have tried the following (live repro: https://tsplay.dev/NDdpVN):
... but I am stuck and haven't found a way to
infer
the param name withinMatch.With
😅Beta Was this translation helpful? Give feedback.
All reactions