Skip to content

Commit e6b84d2

Browse files
committed
move to rescript syntax
1 parent f785ec8 commit e6b84d2

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

_blogposts/2020-09-23-release-8-3.md renamed to _blogposts/2020-09-23-release-8-3.mdx

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ In this release, we make it optional to have `bs.` prefix it or not, this will m
3030
For example, the old externals for `readFileAsUtf8Sync` used to be written like this
3131

3232

33-
```ocaml
34-
external readFileAsUtf8Sync : string -> (_[@bs.as "utf8"]) -> string = "readFileSync" [@@bs.val] [@@bs.module "fs"]
33+
```res
34+
@bs.val @bs.module("fs")
35+
external readFileAsUtf8Sync: (string, @bs.as("utf8") _) => string = "readFileSync"
36+
3537
```
3638

3739
Could be simplified as
38-
```ocaml
39-
external readFileAsUtf8Sync : string -> (_[@as "utf8"]) -> string = "readFileSync"
40-
[@@val] [@@module "fs"]
40+
```res
41+
@val @module("fs") external readFileAsUtf8Sync: (string, @as("utf8") _) => string = "readFileSync"
42+
4143
```
4244

4345
Note almost all previous attributes with `bs.xx` can be simplified as `xx`, except such two that
@@ -53,10 +55,11 @@ backward compatibility.
5355

5456
If you use es6 module output, the default bindings will be compiled properly now:
5557

56-
```ocaml
57-
external input : string -> string = "default" [@@module "hello"]
58+
```res
59+
@module("hello") external input: string => string = "default"
60+
61+
let a = input("hello")
5862
59-
let a = input "hello"
6063
```
6164

6265
Will now be compiled properly under es6 format as below:
@@ -92,15 +95,16 @@ To have better integration with other [JS infrastructures](https://github.com/re
9295

9396
Previously for such piece of code:
9497

95-
```ocaml
96-
module N = struct
97-
type t = {
98-
x : int
99-
}
100-
end
98+
```res
99+
module N = {
100+
type t = {x: int}
101+
}
102+
103+
let f = (u: N.t) => {
104+
let {x} = u
105+
x + 1
106+
} /* type error */
101107
102-
let f (u : N.t) =
103-
let {x } = u in x + 1 (* type error *)
104108
```
105109

106110
You will get a type error

0 commit comments

Comments
 (0)