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: _blogposts/2021-02-09-release-9-0.mdx
+16-5Lines changed: 16 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,14 @@ category: compiler
6
6
title: ReScript 9.0
7
7
badge: release
8
8
description: |
9
+
Featuring a new external stdlib configuration, some syntax improvements and a small breaking change for nested records.
9
10
---
10
11
11
12
## Introduction
12
13
13
14
We are happy to announce ReScript 9.0!
14
15
15
-
ReScript is a strongly typed language that compiles to efficient, fully-typed and human-readable JavaScript. It comes with one of the fastest JS compiler toolchains available today and offers first class support for ReactJS development.
16
+
ReScript is a robustly typed language that compiles to efficientand human-readable JavaScript. It comes with one of the fastest build toolchains and offers first class support for interoperating with ReactJS and other existing JavaScript code.
16
17
17
18
Use `npm` to install the newest [9.0.0 release](https://www.npmjs.com/package/bs-platform/v/9.0.0) with the following command:
18
19
@@ -48,7 +49,7 @@ With this configuration set, compiled JS code will now point to the defined `ext
Now let's have a look at how the JS output would look like in comparison to older versions:
104
+
The snippet above will compile to the following JS output:
104
105
105
106
<CodeTablabels={["9.0 Output", "8.4 Output" ]}>
106
107
@@ -151,6 +152,8 @@ function is_space(param){
151
152
152
153
Starting from 9.0, [`when` clauses](/docs/manual/latest/pattern-matching-destructuring#when-clause) within a `switch` statement will automatically convert to the `if` keyword instead.
153
154
155
+
<CodeTablabels={["New (9.0)", "Old (8.4)"]}>
156
+
154
157
```res
155
158
switch person1 {
156
159
| Student({reportCard: {gpa}}) if gpa < 0.5 =>
@@ -159,8 +162,17 @@ switch person1 {
159
162
}
160
163
```
161
164
162
-
The syntax parser and printer will automatically take care of older code, so no action required for existing codebases. The `when` keyword is deprecated.
165
+
```res
166
+
switch person1 {
167
+
| Student({reportCard: {gpa}}) when gpa < 0.5 =>
168
+
Js.log("What's happening")
169
+
| _ => () // do nothing
170
+
}
171
+
```
163
172
173
+
</CodeTab>
174
+
175
+
The `when` keyword is deprecated. The syntax will continue supporting it and the formatter will automatically convert to `if`, for a pain-free upgrade.
164
176
165
177
### Cleaner Polyvariant Syntax
166
178
@@ -228,7 +240,6 @@ let age = data["user"]["age"]
228
240
229
241
More discussions on this change can be found [here](https://forum.rescript-lang.org/t/fixing-the-semantics-of-nested-objects-breaking-changes/976).
230
242
231
-
232
243
## Closing Note
233
244
234
245
We only highlighted a few user-facing features, but there are also some pretty interesting internal changes happening right now.
0 commit comments