You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: markdown-pages/docs/manual/api.mdx
+2-5Lines changed: 2 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,11 +9,8 @@ canonical: "/docs/manual/api"
9
9
10
10
## Stdlib
11
11
12
-
[Stdlib](/docs/manual/api/stdlib) is ReScript's new standard library. It replaces the complete `Js` module as well as some of the more frequently used modules from `Belt` and is recommended to use with uncurried mode.
13
-
14
-
In ReScript 11, it was shipped as a separate npm package `@rescript/core`.
15
-
16
-
Since Rescript 12, it is now included with the `rescript` npm package itself.
12
+
[Stdlib](/docs/manual/api/stdlib) is ReScript's new builtin standard library.
13
+
It will cover just about you need for day-to-day programming in ReScript and covers most of the built in JavaScript API.
Copy file name to clipboardExpand all lines: markdown-pages/docs/manual/build-configuration.mdx
+1-19Lines changed: 1 addition & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ order: 2
9
9
10
10
# Configuration
11
11
12
-
`rescript.json`(or `bsconfig.json` in versions prior ReScript 11) is the single, mandatory build meta file needed for `rescript`.
12
+
`rescript.json` is the single, mandatory build meta file needed for `rescript`.
13
13
14
14
**The complete configuration schema is [here](./build-configuration-schema.mdx)**. We'll _non-exhaustively_ highlight the important parts in prose below.
15
15
@@ -173,18 +173,6 @@ Generating JS files with the `.res.js` suffix means that, on the JS side, you ca
173
173
- It avoids clashes with a potential `TheFile.js` file in the same folder.
174
174
- It avoids the need of using a build system loader for ReScript files. This + in-source build means integrating a ReScript project into your pure JS codebase **basically doesn't touch anything in your build pipeline at all**.
175
175
176
-
## uncurried
177
-
178
-
**Since 11.0**: While we strongly encourage all users to use uncurried mode, it is still possible to opt out. Just set `"uncurried"` to `false` to get the old behavior back:
179
-
180
-
```json
181
-
{
182
-
"uncurried": false
183
-
}
184
-
```
185
-
186
-
We've also published a blog post on the [transition to the new uncurried mode by default](../../blog/uncurried-mode.mdx).
187
-
188
176
## warnings
189
177
190
178
Selectively turn on/off certain warnings and/or turn them into hard errors. Example:
@@ -238,12 +226,6 @@ To enable genType, set `"gentypeconfig"` at top level in the project's `rescript
238
226
239
227
`debug`: Enable debug logs.
240
228
241
-
### Deprecated options
242
-
243
-
`language`: the `language` setting is not required from compiler v10.1.
244
-
245
-
`shims`: Required only if one needs to export certain basic ReScript data types to JS when one cannot modify the sources to add annotations (e.g. exporting ReScript lists), and if the types are not first-classed in genType.
246
-
247
229
## Environment Variables
248
230
249
231
We heavily disrecommend the usage of environment variables, but for certain cases, they're justified.
> A monorepo is a single repository containing multiple separate projects, with clear relationships between them.
13
13
14
-
ReScript 12.0 introduces improved support for native monorepos through the new "Rewatch" build system. This guide walks you through the setup process.
14
+
ReScript 12.0 introduces improved support for native monorepos through the new ["Rewatch"](../../blog/reforging-build-system.mdx) build system. This guide walks you through the setup process.
15
15
16
16
**Note:** This feature requires the new build system and is **not compatible** with `rescript-legacy`.
Copy file name to clipboardExpand all lines: markdown-pages/docs/manual/editor-plugins.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,7 +39,7 @@ The code analysis provides extra checks for your ReScript project, such as detec
39
39
40
40
### Configuration
41
41
42
-
Add a `reanalyze` section to your `rescript.json` to control what the analyzer checks or ignores. You’ll get autocomplete for config options in the editor.
42
+
Add a `reanalyze` section to your `rescript.json` to control what the analyzer checks or ignores. You'll get autocomplete for config options in the editor.
43
43
More details: [reanalyze config docs](https://github.com/rescript-association/reanalyze#configuration-via-bsconfigjson)
RE_EXN_ID: BadArgument,// `RE_EXN_ID` is an internal API and you should NEVER try and access it from JavaScript
477
477
myMessage:"Oops!",
478
478
Error:newError(),
479
479
};
@@ -494,8 +494,6 @@ try {
494
494
}
495
495
```
496
496
497
-
> Note: `RE_EXN_ID` is an internal field for bookkeeping purposes. Don't use it on the JS side. Use the other fields.
498
-
499
497
The above `BadArgument` exception takes an inline record type. We special-case compile the exception as `{RE_EXN_ID, myMessage, Error}` for good ergonomics. If the exception instead took ordinary positional arguments, l like the standard library's `Invalid_argument("Oops!")`, which takes a single argument, the argument is compiled to JS as the field `_1` instead. A second positional argument would compile to `_2`, etc.
Copy file name to clipboardExpand all lines: markdown-pages/docs/manual/pattern-matching-destructuring.mdx
-2Lines changed: 0 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -504,8 +504,6 @@ if (person1.TAG) {
504
504
505
505
</CodeTab>
506
506
507
-
**Note:** Rescript versions < 9.0 had a `when` clause, not an `if` clause. Rescript 9.0 changed `when` to `if`. (`when` may still work, but is deprecated.)
508
-
509
507
### Match on subtype variants
510
508
511
509
You can refine a variant A to variant B using the [variant type spread syntax](./variant.mdx#variant-type-spreads) in pattern matching. This is possible if variant B [is a subtype of](./variant.mdx#coercion) variant A.
You might see usages of another pipe, `|>`, in some codebases. These are deprecated.
257
-
258
-
Unlike `->` pipe, the `|>` pipe puts the subject as the last (not first) argument of the function. `a |> f(b)` turns into `f(b, a)`.
259
-
260
-
For a more thorough discussion on the rationale and differences between the two operators, please refer to the [Data-first and Data-last comparison by Javier Chávarri](https://www.javierchavarri.com/data-first-and-data-last-a-comparison/)
Copy file name to clipboardExpand all lines: markdown-pages/docs/manual/promise.mdx
+1-69Lines changed: 1 addition & 69 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ order: 21
14
14
15
15
**Since 10.1**
16
16
17
-
In ReScript, every JS promise is represented with the globally available `promise<'a>` type. For ReScript versions < 10.1, use its original alias `Js.Promise.t<'a>` instead.
17
+
In ReScript, every JS promise is represented with the globally available `promise<'a>` type.
18
18
19
19
Here's a usage example in a function signature:
20
20
@@ -36,8 +36,6 @@ A builtin module to create, chain and manipulate promises.
36
36
37
37
```res
38
38
let p1 = Promise.make((resolve, reject) => {
39
-
// We use uncurried functions for resolve / reject
40
-
// for cleaner JS output without unintended curry calls
41
39
resolve("hello world")
42
40
})
43
41
@@ -113,69 +111,3 @@ export { logAsyncMessage };
113
111
```
114
112
115
113
</CodeTab>
116
-
117
-
## Js.Promise module (legacy - do not use)
118
-
119
-
> **Note:** The `Js.Promise` bindings are following the outdated data-last convention from a few years ago. We kept those APIs for backwards compatibility. Either use [`Promise`](/docs/manual/api/stdlib/promise) or a third-party promise binding instead.
120
-
121
-
ReScript has built-in support for [JavaScript promises](/docs/manual/api/stdlib/promise). The 3 functions you generally need are:
Additionally, here's the type signature for creating a promise on the ReScript side:
128
-
129
-
```res
130
-
Js.Promise.make: (
131
-
(
132
-
~resolve: (. 'a) => unit,
133
-
~reject: (. exn) => unit
134
-
) => unit
135
-
) => Js.Promise.t<'a>
136
-
```
137
-
138
-
This type signature means that `make` takes a callback that takes 2 named arguments, `resolve` and `reject`. Both arguments are themselves [uncurried callbacks](./function.mdx#uncurried-function) (with a dot). `make` returns the created promise.
139
-
140
-
### Usage
141
-
142
-
Using the [pipe operator](./pipe.mdx):
143
-
144
-
<CodeTablabels={["ReScript", "JS Output"]}>
145
-
146
-
```res example
147
-
let myPromise = Js.Promise.make((~resolve, ~reject) => resolve(. 2))
148
-
149
-
myPromise->Js.Promise.then_(value => {
150
-
Console.log(value)
151
-
Js.Promise.resolve(value + 2)
152
-
}, _)->Js.Promise.then_(value => {
153
-
Console.log(value)
154
-
Js.Promise.resolve(value + 3)
155
-
}, _)->Js.Promise.catch(err => {
156
-
Console.log2("Failure!!", err)
157
-
Js.Promise.resolve(-2)
158
-
}, _)
159
-
```
160
-
161
-
```js
162
-
var myPromise =newPromise(function (resolve, reject) {
0 commit comments