Syntax Lookup

Enter some language construct you want to know more about.
This is the @module decorator.

The @module decorator is used to bind to a JavaScript module.

Example

ReScriptJS Output
@module("path")
external dirname: string => string = "dirname"

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

Import Attributes

Since 11.1

@module also supports import attributes. It looks like this:

ReScriptJS Output (Module)
@module({from: "./myJson.json", with: {type_: "json", \"some-exotic-identifier": "someValue"}})
external myJson: JSON.t = "default"

Console.log(myJson)

More information in the dedicated documentation for import attributes.

References