Skip to content

Commit 3256eee

Browse files
committed
pr feedback
1 parent a6d34a6 commit 3256eee

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

_blogposts/community/2025-01-01-what-can-i-do-with-rescript.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: |
66
Can I use Vite, or Next.js? Is it only for React? Can I use Node or Deno?
77
---
88

9-
You've taken a look and ReScript and you want to try it out, but how do you get started? There's the [installation](https://rescript-lang.org/docs/manual/latest/installation) page in the docs,
9+
You've taken a look and ReScript and you want to try it out, but how do you get started? There's the [installation](/docs/manual/latest/installation) page in the docs,
1010
which is great if you want to set up a new React app using [create-rescript-app](https://github.com/rescript-lang/create-rescript-app). There's instructions on how to add it to an existing project or set it up manually.
1111
But that doesn't really answer the question "Can I use this with X?".
1212

@@ -23,13 +23,13 @@ Console.log("Hello")
2323
Just run `node index.res.js` and you'll see "Hello" logged to the console. You can import compiled ReScript into any project that could import JavaScript.
2424
If you can use `.js` or `.mjs` files, you can use ReScript. This does mean that languages with different file formats like Vue or Svelte require you to import the compiled JavaScript instead of writing it directly in the `.vue` or `.svelte` files.
2525

26-
Real world projects are more than JavaScript files that you write; they use libraries and frameworks. This is where [bindings](https://rescript-lang.org/docs/manual/latest/external) come into play.
26+
Real world projects are more than JavaScript files that you write; they use libraries and frameworks. This is where [bindings](/docs/manual/latest/external) come into play.
2727
A binding is a way to tell ReScript the types and imports from external JavaScript. You can think of bindings in the same way that you need to create a `*.d.ts` file to add types to a JavaScript library that doesn't use TypeScript.
2828

29-
ReScript has great integration with [React](https://rescript-lang.org/docs/react/latest/introduction) and those bindings are kept up to date by the core team, but that doesn't mean you don't have other options!
29+
ReScript has great integration with [React](/docs/react/latest/introduction) and those bindings are kept up to date by the core team, but that doesn't mean you don't have other options!
3030

3131
## Using existing bindings
32-
While ReScript isn't as large as TypeScript it has a small but growing list of bindings you can find on NPM. The website has a [package explorer](https://rescript-lang.org/packages) you can use to find official and community maintained bindings.
32+
While ReScript isn't as large as TypeScript it has a small but growing list of bindings you can find on NPM. The website has a [package explorer](/packages) you can use to find official and community maintained bindings.
3333
Many major libraries have existing bindings. Here's a small set of what you can find.
3434

3535
- [Node](https://github.com/TheSpyder/rescript-nodejs)
@@ -59,7 +59,7 @@ You can also get help and guidance on how to write bindings for what you need. U
5959
You don't need to write bindings for an entire library, or even for all of a functions arguments. Just write what you need as you go.
6060

6161
Let's take a look at the `format` function from [date-fns](https://date-fns.org/). We can see the [arguments in the docs](https://date-fns.org/v4.1.0/docs/format#arguments), and how it should be imported and used.
62-
```typescript
62+
```ts
6363
// type signature
6464
function format(
6565
date: string | number | Date,
@@ -75,8 +75,8 @@ const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
7575
```
7676

7777
That's all we need to know to write bindings to use this function in ReScript.
78-
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](https://rescript-lang.org/docs/manual/latest/variant) to map to the possible input types.
79-
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](https://rescript-lang.org/docs/manual/latest/function#labeled-arguments) for our binding.
78+
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.
79+
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.
8080
```res
8181
// DateFns.res - you might want to put this in a folder called "bindings" or "external"
8282
type formatDateOptions // we're not even going to add anything to this yet until we need something
@@ -135,7 +135,7 @@ var formattedDate = DateFns.format("2021-09-01", "MMMM dd, yyyy", {
135135
You can write new bindings and extend existing types as you need.
136136

137137
## How can I get started?
138-
You can [follow this guide](https://rescript-lang.org/docs/manual/v11.0.0/converting-from-js) to add ReScript to an existing JavaScript project to get a feel for how the language works and interacts with JavaScript.
138+
You can [follow this guide](/docs/manual/v11.0.0/converting-from-js) to add ReScript to an existing JavaScript project to get a feel for how the language works and interacts with JavaScript.
139139
The forum is also a great place to ask questions! Feel free to drop by and ask how to get started with a specific framework or project that you want to work on,
140140
and you'll probably get great advice and information from users who have already used ReScript for something similar.
141141

0 commit comments

Comments
 (0)