ziggy-js 2.6.2 → 2.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/js/index.d.ts +22 -9
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Ziggy – Use your Laravel routes in JavaScript
|
|
4
4
|
|
|
5
|
-
[](https://github.com/tighten/ziggy/actions/workflows/test.yml)
|
|
6
6
|
[](https://packagist.org/packages/tightenco/ziggy)
|
|
7
7
|
[](https://packagist.org/packages/tightenco/ziggy)
|
|
8
8
|
[](https://npmjs.com/package/ziggy-js)
|
package/package.json
CHANGED
package/src/js/index.d.ts
CHANGED
|
@@ -24,9 +24,10 @@ type RouteName = KnownRouteName | (string & {});
|
|
|
24
24
|
// See https://stackoverflow.com/a/61048124/6484459.
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* A generated route URL string.
|
|
27
|
+
* A generated route URL string, branded to distinguish it from a plain string.
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
declare const RouteUrlBrand: unique symbol;
|
|
30
|
+
export type RouteUrl = string & { readonly [RouteUrlBrand]: typeof RouteUrlBrand };
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* A valid route name to pass to `route()` to generate a URL.
|
|
@@ -114,16 +115,28 @@ type RouteParamsObject<N extends RouteName> = N extends KnownRouteName
|
|
|
114
115
|
type GenericRouteParamsArray = unknown[];
|
|
115
116
|
/**
|
|
116
117
|
* An array of parameters for a specific named route.
|
|
118
|
+
*
|
|
119
|
+
* Required parameters come first as required tuple elements, then optional
|
|
120
|
+
* parameters become optional tuple elements, followed by arbitrary extras.
|
|
117
121
|
*/
|
|
118
122
|
type KnownRouteParamsArray<I extends readonly ParameterInfo[]> = [
|
|
119
|
-
...
|
|
120
|
-
...
|
|
123
|
+
...RequiredParamsTuple<I>,
|
|
124
|
+
...OptionalParamsTuple<I>,
|
|
121
125
|
];
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
126
|
+
|
|
127
|
+
type RequiredParamsTuple<I extends readonly ParameterInfo[]> =
|
|
128
|
+
I extends readonly [infer F extends ParameterInfo, ...infer R extends ParameterInfo[]]
|
|
129
|
+
? F extends { required: true }
|
|
130
|
+
? [Routable<F>, ...RequiredParamsTuple<R>]
|
|
131
|
+
: []
|
|
132
|
+
: [];
|
|
133
|
+
|
|
134
|
+
type OptionalParamsTuple<I extends readonly ParameterInfo[]> =
|
|
135
|
+
I extends readonly [infer F extends ParameterInfo, ...infer R extends ParameterInfo[]]
|
|
136
|
+
? F extends { required: false }
|
|
137
|
+
? [Routable<F>?, ...OptionalParamsTuple<R>]
|
|
138
|
+
: OptionalParamsTuple<R>
|
|
139
|
+
: [...unknown[]];
|
|
127
140
|
|
|
128
141
|
// Uncomment to test:
|
|
129
142
|
// type B = KnownRouteParamsArray<[{ name: 'post'; required: true; binding: 'uuid' }]>;
|