@@ -36,6 +36,8 @@ export function hello() {
3636And this F# code:
3737
3838``` fs
39+ open Fable.Core
40+
3941[<Import("hello", "./hello.js")>]
4042let hello : unit -> unit = jsNative
4143
@@ -64,6 +66,8 @@ There are 2 families of imports:
6466They archieve the same goal, but with a slightly generated code.
6567
6668``` fs
69+ open Fable.Core
70+
6771[<Import("hello", "./hello.js")>]
6872let hello : unit -> unit = jsNative
6973
@@ -93,13 +97,17 @@ Some JavaScript optimizations tools can remove the intermediate variable, but no
9397When trying to bind a global variable, you can use the ` [<Global>] ` attribute.
9498
9599``` fs
100+ open Fable.Core
101+
96102[<Global>]
97103let console: JS.Console = jsNative
98104```
99105
100106If you want to use a different in you F# code, you can use the ` name ` parameter:
101107
102108``` fs
109+ open Fable.Core
110+
103111[<Global("console")>]
104112let logger: JS.Console = jsNative
105113```
@@ -112,6 +120,8 @@ This attributes takes two parameters:
112120- ` from ` : the path to the JavaScript file / module
113121
114122``` fs
123+ open Fable.Core
124+
115125[<Import("hello", "./hello.js")>]
116126let hello : unit -> unit = jsNative
117127// Generates: import { hello } from "./hello.js";
@@ -130,6 +140,8 @@ let hello : unit -> unit = jsNative
130140` ImportAll ` is used to import all members from a JavaScript module and use the F# value name as the name of the imported module.
131141
132142``` fs
143+ open Fable.Core
144+
133145[<ImportAll("./hello.js")>]
134146let hello : unit -> unit = jsNative
135147// Generates: import * as hello from "./hello.js";
@@ -140,6 +152,8 @@ let hello : unit -> unit = jsNative
140152` ImportMember ` is used to import a specific member from a JavaScript module, the name is based on the name of the F# value.
141153
142154``` fs
155+ open Fable.Core
156+
143157[<ImportMember("./hello.js")>]
144158let hello : unit -> unit = jsNative
145159// Generates: import { hello } from "./hello.js";
@@ -150,6 +164,8 @@ let hello : unit -> unit = jsNative
150164` ImportDefault ` is used to import the default member from a JavaScript module, the name is based on the name of imported module.
151165
152166``` fs
167+ open Fable.Core
168+
153169[<ImportDefault("./hello.js")>]
154170let hello : unit -> unit = jsNative
155171// Generates: import hello from "./hello.js";
0 commit comments