Skip to content

Commit b1e3f8a

Browse files
authored
Merge branch 'gleam-lang:main' into gleam-for-javascript-users
2 parents c035807 + 92459d0 commit b1e3f8a

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

_data/sponsors.yml

+5
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,11 @@
658658
avatar: "https://avatars.githubusercontent.com/u/24900688?u=f55f5ef982cc7b992eadd7f58fa34dc7abd45233&v=4"
659659
tier: 2
660660
square_avatar: false
661+
- name: "Xetera"
662+
url: "https://github.com/Xetera"
663+
avatar: "https://avatars.githubusercontent.com/u/24978328?u=e4286d30bfd5917cc750729b877316610cd41c13&v=4"
664+
tier: 1
665+
square_avatar: false
661666
- name: "Zsombor Gasparin"
662667
url: "https://github.com/gasparinzsombor"
663668
avatar: "https://avatars.githubusercontent.com/u/25465322?u=18186bbf5e9df8274c5795f2d8359a06ebf0885c&v=4"

book-src/tour/custom-types.md

+22
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,25 @@ LoggedIn("Kim")
250250
guest,
251251
{logged_in, <<"Kim">>}.
252252
```
253+
254+
## JavaScript interop
255+
256+
When compiling to JavaScript, each constructor becomes a class of the same name.
257+
Each of the generated JavaScript classes has a constructor with the same
258+
arguments as the original type constructor.
259+
260+
```gleam
261+
// Gleam
262+
Guest
263+
LoggedIn("Kim")
264+
Cat(name: "Jinx", cuteness: 2002)
265+
```
266+
267+
```javascript
268+
// JavaScript
269+
import { Guest, LoggedIn, Cat } from "my_module.mjs";
270+
271+
new Guest();
272+
new LoggedIn("Kim");
273+
new Cat("Jinx", 2002);
274+
```

0 commit comments

Comments
 (0)