Why Js.Option.getWithDefault() don't use option as first parameter

Why Js.Option.getWithDefault() don’t use option as first parameter?If so ,we can use it like
let somebody = Some(“jack”)
jack.getWithDefault(“lee”)

From the Js API Doc (Js | ReScript API):

Argument Order

For historical reasons, some APIs in the Js namespace (e.g. Js.String) are using the data-last argument order whereas others (e.g. Js.Date) are using data-first.

For more information about these argument orders and the trade-offs between them, see this blog post.

Eventually, all modules in the Js namespace are going to be migrated to data-first though.

In the meantime, there are several options for dealing with the data-last APIs:

2 Likes

…and you can use Belt.Option.getWithDefault for the data-first API. It has the idiomatic argument order.

3 Likes

Thanks a lot!It works。It seems that code intellisense in vscode can’t handle this situation。like this:

let somebody = Some(“jack”)
somebody->

the plugin didnt return tips

Works fine for me.
file a bug on rescript-vscode if the issue persisted.