@@ -7,13 +7,12 @@ title: What's new in ReScript 8.3 (Part 1)
7
7
description : |
8
8
---
9
9
10
+ ## Introduction
10
11
11
- # What's new in ReScript 8.3 (Part 1)
12
-
13
- ReScript is a soundly typed language with an optimizing compiler focused on JS platform.
12
+ ReScript is a soundly typed language with an optimizing compiler focused on the JS platform.
14
13
It's focused on type safety, performance and JS interop. It used to be called BuckleScript.
15
14
16
- [email protected] is available
, people can try it via
15
+ [ [email protected] ] ( https://www.npmjs.com/package/bs-platform/v/8.3.0 ) is
now available
for testing, you can try it via
17
16
18
17
```
19
18
@@ -31,6 +30,7 @@ For example, the old externals for `readFileAsUtf8Sync` used to be written like
31
30
32
31
33
32
<CodeTab labels = { [" ReScript" , " Reason" , " ML" ]} >
33
+
34
34
``` res
35
35
@bs.val @bs.module("fs")
36
36
external readFileAsUtf8Sync: (string, @bs.as("utf8") _) => string = "readFileSync"
@@ -43,10 +43,13 @@ external readFileAsUtf8Sync: (string, [@bs.as "utf8"] _) => string =
43
43
``` ocaml
44
44
external readFileAsUtf8Sync : string -> (_[@bs.as "utf8"]) -> string = "readFileSync" [@@bs.val] [@@bs.module "fs"]
45
45
```
46
+
46
47
</CodeTab >
47
48
48
49
It can now be simplified as
50
+
49
51
<CodeTab labels = { [" ReScript" , " Reason" , " ML" ]} >
52
+
50
53
``` res
51
54
@val @module("fs") external readFileAsUtf8Sync: (string, @as("utf8") _) => string = "readFileSync"
52
55
```
@@ -59,6 +62,7 @@ external readFileAsUtf8Sync: (string, [@as "utf8"] _) => string =
59
62
external readFileAsUtf8Sync : string -> (_[@as "utf8"]) -> string = "readFileSync"
60
63
[@@val] [@@module "fs"]
61
64
```
65
+
62
66
</CodeTab >
63
67
64
68
Note almost all previous attributes with ` bs.xx ` can be simplified as ` xx `
@@ -75,6 +79,7 @@ backward compatibility.
75
79
If you use es6 module output, the default bindings will be compiled properly now:
76
80
77
81
<CodeTab labels = { [" ReScript" , " Reason" , " ML" ]} >
82
+
78
83
``` res
79
84
@module("hello") external input: string => string = "default"
80
85
@@ -90,6 +95,7 @@ external input : string -> string = "default" [@@module "hello"]
90
95
91
96
let a = input "hello"
92
97
```
98
+
93
99
</CodeTab >
94
100
95
101
Will now be compiled properly under es6 format as below:
@@ -128,6 +134,7 @@ for example, Next.js/React Native, we allow file names like `404.res`,
128
134
Previously, for code like this:
129
135
130
136
<CodeTab labels = { [" ReScript" , " Reason" , " ML" ]} >
137
+
131
138
``` res
132
139
module N = {
133
140
type t = {x: int}
158
165
let f (u : N.t) =
159
166
let {x } = u in x + 1 (* type error *)
160
167
```
168
+
161
169
</CodeTab >
162
170
163
171
You will get a type error
@@ -174,4 +182,4 @@ like `let {N.x} = ..`
174
182
175
183
A lot of work is put in improving the build system, we will expand on this topic in the next post!
176
184
177
- Happy Hacking!
185
+ Happy Hacking!
0 commit comments