rescript-lang / rescript-core

A drop-in standard library for ReScript. Intended to be familiar for JavaScript developers, easy to use, and be rich enough (without being bloated) so that you don't need to reach for anything else for typical ReScript development.
MIT License
162 stars 28 forks source link

Intl types: simplify bindings for constructors / functions with optional arguments #198

Closed cknitt closed 8 months ago

cknitt commented 8 months ago

Now that we can have functions with optional arguments without a trailing () in ReScript 11 uncurried mode, bindings can be simplified to a single make function (and the same for supportedLocalesOf) with nice ergonomics.

I also think we can drop the distinction between passing a single locale and an array of locales. Just pass an array always.

One minor downside are trailing undefined params in the JS output. This is probably something we should improve in the compiler, but it shouldn't do any harm here.

@zth @illusionalsagacity @glennsl For now I just did it for Intl.Collator. If this looks good to you, I would extend it to the other types.

(The first commit just removes duplicate build artifacts that were in test/intl plus test/Intl).

zth commented 8 months ago

I like this, and this is a conversion we should do for more APIs. As in combine variants that can be a single function with optional args now with v11.

We should optimize the compiler to not print the undefineds unless needed. There's an issue for it somewhere and me and @cristianoc have been chatting about it too before.

cknitt commented 8 months ago

@zth @illusionalsagacity @glennsl For now I just did it for Intl.Collator. If this looks good to you, I would extend it to the other types.

Extended to the remaining Intl types, please re-review.