Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax lookup: external #246

Merged
merged 3 commits into from
Mar 9, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions misc_docs/syntax/language_external.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
id: "external"
keywords: ["external", "javascript"]
name: "external"
summary: "This is the `external` language construct."
ryyppy marked this conversation as resolved.
Show resolved Hide resolved
category: "languageconstructs"
---

`external` is used to bind ReScript code to [external JS code](/docs/manual/latest/external), including binding 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).
ryyppy marked this conversation as resolved.
Show resolved Hide resolved


### Example

<CodeTab labels={["ReScript", "JS Output"]}>

```res
@module("path")
external dirname: string => string = "dirname"

let root = dirname("/User/github")
```

```js
var Path = require("path");
var root = Path.dirname("/User/github");
```

</CodeTab>

### References

* [External (Bind to Any JS Library)](/docs/manual/latest/external)
* [Bind to JS Object](/docs/manual/latest/bind-to-js-object)
* [Bind to JS Function](/docs/manual/latest/bind-to-js-function)
* [Import From JavaScript](/docs/manual/latest/import-from-export-to-js#import-from-javascript)
* [Bind to Global JS Values](/docs/manual/latest/bind-to-global-js-values)