This PR does two things: it adds types for Ziggy itself, and it adds the ability to generate type declarations specific to a user's list of routes. Credit for most of this goes to @lmeysel for the original implementation in #655.
Types
This PR adds an index.d.ts file containing type definitions for Ziggy itself. These types will be maintained manually since Ziggy is written in JavaScript. Out of the box they should be able to replace @types/ziggy-js and provide much smoother autocompletion and type hinting for end users.
They're currently tested manually using tests/js/types.ts, which contains sample Ziggy code that should or shouldn't produce type errors.
User route types
This PR also adds --types and --types-only options to the ziggy:generate command to generate a ziggy.d.ts file containing additional types specific to the app using Ziggy. This file extends Ziggy's RouteList interface to list the names and some basic parameter metadata about all the routes in the app, which allows IDE autocompletion of routes and parameter names while using the route() function.
This PR does two things: it adds types for Ziggy itself, and it adds the ability to generate type declarations specific to a user's list of routes. Credit for most of this goes to @lmeysel for the original implementation in #655.
Types
This PR adds an
index.d.ts
file containing type definitions for Ziggy itself. These types will be maintained manually since Ziggy is written in JavaScript. Out of the box they should be able to replace@types/ziggy-js
and provide much smoother autocompletion and type hinting for end users.They're currently tested manually using
tests/js/types.ts
, which contains sample Ziggy code that should or shouldn't produce type errors.User route types
This PR also adds
--types
and--types-only
options to theziggy:generate
command to generate aziggy.d.ts
file containing additional types specific to the app using Ziggy. This file extends Ziggy'sRouteList
interface to list the names and some basic parameter metadata about all the routes in the app, which allows IDE autocompletion of routes and parameter names while using theroute()
function.