zth / rescript-relay-router

MIT License
16 stars 3 forks source link

[Feature Request] Move non-optional arguments last in functions #25

Closed Kingdutch closed 2 years ago

Kingdutch commented 2 years ago

I found at least one example where a non-optional parameter comes before an optional named parameter. This results in making the optional named parameter non-optional or requiring another unit argument.

https://github.com/zth/rescript-relay-router/blob/5b540248e2a29ebeb57fcfc6f6b2ddb39a1e6535/cli/RescriptRelayRouterCli__Codegen.res#L590

I would propose to change this to

let isRouteActive = (~exact: bool=false, {pathname}: RelayRouter.Bindings.History.location): bool => {

This enables the following to work without errors:

Route.isRouteActive(location)
Route.isRouteActive(~exact=false, location)
location->Route.isRouteActive
location->Route.isRouteActive(~exact=false)

We can use this issue to find other places where ergonomics can be improved.

zth commented 2 years ago

Yes, this sounds great, good catch!