Skip to content

Commit 2d2e0d8

Browse files
committed
Several corrections
1 parent e6da76a commit 2d2e0d8

12 files changed

+24
-20
lines changed

pages/docs/manual/latest/converting-from-js.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ let queryResult = (usePayload, payload) =>
5959

6060
You might still occasionally get syntax errors, but not as drastic as the previous step's.
6161

62-
- Change `foo.bar` to `foo["bar"]`. This escape-hatch [ReScript feature](/docs/reason-compiler/latest/object) will be your medium-term friend.
62+
- Change `foo.bar` to `foo["bar"]`. This escape-hatch [ReScript feature](object.md) will be your medium-term friend.
6363
- To communicate with external JS files, use `external`. They're our [foreign function interface](external.md).
6464
- Inline externals. No need to create clean, well-separated files for externals for now. We'll come back to these.
6565
- If it's too cumbersome to correctly type an `external`'s input/output, use some placeholder polymorphic types, e.g. `external getStudentById: 'whatever => 'whateverElse = ...`.
@@ -75,7 +75,7 @@ let defaultId = 10
7575
7676
let queryResult = (usePayload, payload) =>
7777
if usePayload {
78-
payload["student"] // this will be inferred as `Js.t 'a`
78+
payload["student"] // this will be inferred as `Js.t<'a>`
7979
} else {
8080
getStudentById(defaultId)
8181
};

pages/docs/manual/latest/exception.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Exceptions are just a special kind of variant, thrown in **exceptional** cases (
77
<CodeTab labels={["ReScript", "JS Output"]}>
88

99
```res
10-
let getItem = (theList) =>
10+
let getItem = (items) =>
1111
if callSomeFunctionThatThrows() {
1212
// return the found item here
1313
1
@@ -23,7 +23,7 @@ let result =
2323
}
2424
```
2525
```js
26-
function getItem(theList) {
26+
function getItem(items) {
2727
if (callSomeFunctionThatThrows()) {
2828
return 1;
2929
}
@@ -153,7 +153,7 @@ The `obj` here is of type `Js.Exn.t`, intentionally opaque to disallow illegal o
153153

154154
## Raise a JS Exception
155155

156-
`raise MyException` raises a ReScript exception. To raise a JavaScript exception (whatever your purpose is), use `Js.Exn.raiseError`:
156+
`raise(MyException)` raises a ReScript exception. To raise a JavaScript exception (whatever your purpose is), use `Js.Exn.raiseError`:
157157

158158
<CodeTab labels={["ReScript", "JS Output"]}>
159159

pages/docs/manual/latest/faq.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ Reason is a syntax layer for OCaml that BuckleScript also adopted. The current R
2020

2121
Please see our [blog post](https://reasonml.org/blog/a-note-on-bucklescripts-future-commitments) on this matter.
2222

23+
**Where can I see the docs in old Reason syntax?**
24+
25+
Switch the doc version to `v8.0.0` in the sidebar on the left!
26+
2327
**Will ReScript support native compilation eventually?**
2428

2529
Our focus is a solid JS story right now. In the future, if there’s strong demand, we might consider it.

pages/docs/manual/latest/function.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,8 @@ let add = (~first: int=1, ~second: int=2) : int => first + second
458458
// optional
459459
let add = (~first as x: option<int>=?, ~second as y: option<int>=?) : int => switch x {...}
460460
// with punning sugar
461-
// note that the caller would pass an `int`, not `option int`
462-
// Inside the function, `first` and `second` are `option int`.
461+
// note that the caller would pass an `int`, not `option<int>`
462+
// Inside the function, `first` and `second` are `option<int>`.
463463
let add = (~first: option<int>=?, ~second: option<int>=?) : int => switch first {...}
464464
```
465465

pages/docs/manual/latest/import-from-export-to-js.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Technically, since a ReScript file maps to a module, there's no such thing as "d
9494
<CodeTab labels={["ReScript", "JS Output"]}>
9595

9696
```res
97-
/* FavoriteStudent.ml */
97+
/* FavoriteStudent.res */
9898
let default = "Bob"
9999
```
100100
```js

pages/docs/manual/latest/migrate-from-bucklescript-reason.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ ReScript is a rebranding and cleanup of BuckleScript & Reason that enables us to
77

88
## Upgrade Your Codebase
99

10-
There are lots of exciting improvements in the new syntax (features, speed, error messages, etc.). The upgrade is trivial and backward-compatible:
10+
There are lots of exciting improvements in the new syntax (features, speed, error messages, etc.). The upgrade is trivial, backward-compatible and can be done on a per-file basis:
1111

1212
- Upgrade your project to `bs-platform 8.2.0`.
1313
- `node_modules/.bin/bsc -format MyFile.re > MyFile.res`
1414

15-
**That's it**! You can convert over your files one by one. `MyFile.re` could be any `.re`, `.rei`, `.ml` and `.mli` file.
15+
**That's it**! `MyFile.re` could be any `.re`, `.rei`, `.ml` and `.mli` file.
1616

1717
Enjoy the improved experience!

pages/docs/manual/latest/newcomer-examples.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type universityStudent = {gpa: float}
4242
4343
type response<'studentType> = {
4444
status: int,
45-
student: 'studentType
45+
student: 'studentType,
4646
}
4747
```
4848
```js
@@ -77,7 +77,7 @@ Or using [record](record.md):
7777
```res
7878
type payload = {
7979
name: string,
80-
age: int
80+
age: int,
8181
}
8282
8383
let student1 = {

pages/docs/manual/latest/object.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ let me = {
4444
}
4545
```
4646
```js
47-
bar me = {
47+
var me = {
4848
"age": 5,
4949
"name": "Big ReScript"
5050
};

pages/docs/manual/latest/overview.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
| JavaScript | Us |
2121
| ----------------------- | ------------------------------ |
22-
| `const x = 5;` | `let x = 5` |
22+
| `const x = 5;` | `let x = 5` |
2323
| `var x = y;` | No equivalent (thankfully) |
2424
| `let x = 5; x = x + 1;` | `let x = ref(5); x := x.contents + 1` |
2525

@@ -36,7 +36,7 @@
3636

3737
| JavaScript | Us |
3838
| ----------------------------------------------------- | ---------------------------------------------- |
39-
| `true`, `false` | Same |
39+
| `true`, `false` | Same |
4040
| `!true` | Same |
4141
| <code>&#124;&#124;</code>, `&&`, `<=`, `>=`, `<`, `>` | Same |
4242
| `a === b`, `a !== b` | Same |
@@ -69,7 +69,7 @@
6969

7070
| JavaScript | Us |
7171
| --------------------- | ---------------------------------- |
72-
| `[1, 2, 3]` | Same |
72+
| `[1, 2, 3]` | Same |
7373
| `myArray[1] = 10` | Same |
7474
| `[1, "Bob", true]` | `(1, "Bob", true)` \* |
7575

pages/docs/manual/latest/pipe.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Assuming we don't need the chaining behavior above, we'd bind to each case this
9090
@bs.send external filter: (array<'a>, 'a => bool) => array<'a> = "filter"
9191
9292
type request
93-
external asyncRequest: unit => request = "asyncRequest"
93+
@bs.val external asyncRequest: unit => request = "asyncRequest"
9494
@bs.send external setWaitDuration: (request, int) => request = "setWaitDuration"
9595
@bs.send external send: request => unit = "send"
9696
```
@@ -128,7 +128,7 @@ This looks much worse than the JS counterpart! Clean it up visually with pipe:
128128
```res
129129
let result = [1, 2, 3]
130130
->map(a => a + 1)
131-
->filter(a => a mod 2 === 0)
131+
->filter(a => mod(a, 2) === 0)
132132
133133
asyncRequest()->setWaitDuration(4000)->send
134134
```

0 commit comments

Comments
 (0)