What's Changed?
-
Removal of
create_link_generator
FunctionThe
create_link_generator
function has been removed and replaced by a new function,link_generator
. Thelink_generator
function now accepts aroute_config
object, internally calls theflatten_route_config
function, and transforms it into aMap
. This approach allows for high-speed link generation through the returnedlink
function.const route_config = { products: { path: "/products", }, } as const satisfies RouteConfig; const link = link_generator(route_config); link("products"); // => '/products'
-
Deprecation of
flatten_route_config
FunctionThe
flatten_route_config
function was previously public because it enabled easy visual representation of the flattened types while generating thelink
function increate_link_generator
. It was also meant to save the effort of creating specific type definitions to obtain the flattened types. However, this restricted the ability to make breaking changes to theflatten_route_config
function. Since thelink_generator
function now calls this internally in version 9, there is no longer a need to keep it public. -
Modification of
link
Function API to Accept Any Number of Query ObjectsThe previous
link
function had a limitation where multiple identical query parameters could not be generated. This has been resolved in version 9, and thelink
function has been modified to accept any number of query objects starting from the third argument.const route_config = { products: { path: "/products?color&size", } } as const satisfies RouteConfig; const link = link_generator(route_config); link('products', undefined, { color: 'red' }, { color: 'blue' }, { color: 'green', size: 'small' }); // => /products?color=red&color=blue&color=green&size=small
-
Improved Code Readability
Variable and function names used internally have been clarified to enhance code readability.