Comparing version 2.4.2 to 2.5.0
{ | ||
"name": "ziggy-js", | ||
"version": "2.4.2", | ||
"version": "2.5.0", | ||
"description": "Use your Laravel named routes in JavaScript.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -553,3 +553,3 @@ ![Ziggy - Use your Laravel routes in JavaScript](https://raw.githubusercontent.com/tighten/ziggy/main/ziggy-banner.png) | ||
If you are generating your Ziggy config as a file by running `php artisan ziggy:generate`, you may want to re-run that command when your app's route files change. The example below is a Laravel Mix plugin, but similar functionality could be achieved without Mix. Huge thanks to [Nuno Rodrigues](https://github.com/nacr) for [the idea and a sample implementation](https://github.com/tighten/ziggy/issues/321#issuecomment-689150082). See [#655 for a Vite example](https://github.com/tighten/ziggy/pull/655/files#diff-4aeb78f813e14842fcf95bdace9ced23b8a6eed60b23c165eaa52e8db2f97b61). | ||
If you are generating your Ziggy config as a file by running `php artisan ziggy:generate`, you may want to re-run that command when your app's route files change. The example below is a Laravel Mix plugin, but similar functionality could be achieved without Mix. Huge thanks to [Nuno Rodrigues](https://github.com/nacr) for [the idea and a sample implementation](https://github.com/tighten/ziggy/issues/321#issuecomment-689150082). See [#655](https://github.com/tighten/ziggy/pull/655/files#diff-4aeb78f813e14842fcf95bdace9ced23b8a6eed60b23c165eaa52e8db2f97b61) or [vite-plugin-ziggy](https://github.com/aniftyco/vite-plugin-ziggy) for Vite examples. | ||
@@ -556,0 +556,0 @@ <details> |
@@ -1,3 +0,1 @@ | ||
import { ParsedQs } from 'qs'; | ||
/** | ||
@@ -23,5 +21,3 @@ * A list of routes and their parameters and bindings. | ||
*/ | ||
type RouteName = TypeConfig extends { strictRouteNames: true } | ||
? KnownRouteName | ||
: KnownRouteName | (string & {}); | ||
type RouteName = KnownRouteName | (string & {}); | ||
// `(string & {})` prevents TypeScript from reducing this type to just `string`, | ||
@@ -32,2 +28,7 @@ // which would prevent intellisense from autocompleting known route names. | ||
/** | ||
* A valid route name to pass to `route()` to generate a URL. | ||
*/ | ||
type ValidRouteName = TypeConfig extends { strictRouteNames: true } ? KnownRouteName : RouteName; | ||
/** | ||
* Information about a single route parameter. | ||
@@ -165,2 +166,7 @@ */ | ||
// qs's parsed query params type, so we don't have to have qs as a dependency | ||
interface ParsedQs { | ||
[key: string]: undefined | string | string[] | ParsedQs | ParsedQs[]; | ||
} | ||
/** | ||
@@ -193,3 +199,3 @@ * Ziggy's Router class. | ||
// Called with a route name and optional additional arguments - returns a URL string | ||
export function route<T extends RouteName>( | ||
export function route<T extends ValidRouteName>( | ||
name: T, | ||
@@ -201,3 +207,3 @@ params?: RouteParams<T> | undefined, | ||
export function route<T extends RouteName>( | ||
export function route<T extends ValidRouteName>( | ||
name: T, | ||
@@ -204,0 +210,0 @@ params?: ParameterValue | undefined, |
44499
246