kruschid / typesafe-routes

Spices up your favorite routing library by adding type safety to plain string-based route definitions.
https://kruschid.github.io/typesafe-routes/
MIT License
102 stars 8 forks source link

Wrong routes in the documentation ? #50

Open Xample opened 4 months ago

Xample commented 4 months ago

Hi, regarding this file:

https://github.com/kruschid/typesafe-routes/edit/master/docs/basic-features/parameter-types.md

In many examples we do have

import { createRoutes, oneOf } from "typesafe-routes";

const options = oneOf("movies", "music", "art")

const routes = createRoutes({
  home: ["home", options("category")] // <- wrong
});

routes.render("home", {path: {category: "music"}}); // => "/home/music"
routes.parseParams("home", "/home/art"); // => {category: "art"}

i.e. home: ["home", options("category")]

this won't compile, it should be

const routes = createRoutes({
    home: { path: ['home', options('category')] },
});

As I found this mistake in many places (in the same file) I was wondering if this is a real error or just a kind of upcomming shorthand for the path that I missed.