Skip to content

Commit f59dca7

Browse files
authored
Merge pull request #246 from kevanstannard/syntax-lookup-external
Syntax lookup: external
2 parents 94f1416 + 41c629d commit f59dca7

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
id: "external"
3+
keywords: ["external", "javascript"]
4+
name: "external"
5+
summary: "This is the `external binding` keyword."
6+
category: "languageconstructs"
7+
---
8+
9+
`external` is used to bind ReScript code to [external JS code](/docs/manual/latest/external), including bindings to [global values](/docs/manual/latest/bind-to-global-js-values), [modules](/docs/manual/latest/import-from-export-to-js#import-from-javascript), [functions](/docs/manual/latest/bind-to-js-function) and [objects](/docs/manual/latest/bind-to-js-object).
10+
11+
12+
### Example
13+
14+
<CodeTab labels={["ReScript", "JS Output"]}>
15+
16+
```res
17+
@module("path")
18+
external dirname: string => string = "dirname"
19+
20+
let root = dirname("/User/github")
21+
```
22+
23+
```js
24+
var Path = require("path");
25+
var root = Path.dirname("/User/github");
26+
```
27+
28+
</CodeTab>
29+
30+
### References
31+
32+
* [External (Bind to Any JS Library)](/docs/manual/latest/external)
33+
* [Bind to JS Object](/docs/manual/latest/bind-to-js-object)
34+
* [Bind to JS Function](/docs/manual/latest/bind-to-js-function)
35+
* [Import From JavaScript](/docs/manual/latest/import-from-export-to-js#import-from-javascript)
36+
* [Bind to Global JS Values](/docs/manual/latest/bind-to-global-js-values)

0 commit comments

Comments
 (0)