-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Closed as not planned
Closed as not planned
Copy link
Labels
DailyKSv2KSv2ExternalAdded to denote the issue can be worked on by a contributorAdded to denote the issue can be worked on by a contributorNewFeatureSomething to build that is a new item.Something to build that is a new item.
Description
Coming from #31543 (comment)...
Problem
We've got some types that look like this:
function getUrlWithBackToParam<TUrl extends string>(url: TUrl, backTo?: string): `${TUrl}` | `${TUrl}?backTo=${string}` | `${TUrl}&backTo=${string}` {
...
}and while that works it's a pretty verbose way to express a pretty common format for something.
Solution
This is a rich representation of what this string could / should look like, instead of just being string, but let's clean this up to make it more extensible/reusable. We should make a utility type for URLs that takes:
- A base URL
- an object type representing a series of optional or required query params (which of course can be in any order)
Then the resultant type would be any string matching the pattern of a valid URL with the correct base and query params.
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~01ab405b1ad68ca814
- Upwork Job ID: 1729557018701299712
- Last Price Increase: 2023-11-28
Reactions are currently unavailable
Metadata
Metadata
Labels
DailyKSv2KSv2ExternalAdded to denote the issue can be worked on by a contributorAdded to denote the issue can be worked on by a contributorNewFeatureSomething to build that is a new item.Something to build that is a new item.