Skip to content

Commit

Permalink
typo
Browse files Browse the repository at this point in the history
  • Loading branch information
jderochervlk committed Mar 4, 2025
1 parent 3256eee commit 918d637
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')

That's all we need to know to write bindings to use this function in ReScript.
The first thing we need to figure out is how to handle the type for what `date-fns` considers to be a `date`, which is `Date | string | number`. In ReScript things can't just be of different types like they can in JavaScript or TypeScript. There are a couple options here; you can make a function for each type such as `formatString` and `formatDate`, or you can create a [variant type](/docs/manual/latest/variant) to map to the possible input types.
Creating a function for each type is simpler, and it's most likely how you will use the library in your project. You probably have a standard type for Dates already. We'll also need a type for `FormatDateOptions` in case we want to pass options. We'll use [labled arguments](/docs/manual/latest/function#labeled-arguments) for our binding.
Creating a function for each type is simpler, and it's most likely how you will use the library in your project. You probably have a standard type for Dates already. We'll also need a type for `FormatDateOptions` in case we want to pass options. We'll use [labeled argmuments](/docs/manual/latest/function#labeled-arguments) for our binding.
```res
// DateFns.res - you might want to put this in a folder called "bindings" or "external"
type formatDateOptions // we're not even going to add anything to this yet until we need something
Expand Down

0 comments on commit 918d637

Please sign in to comment.