Skip to content

Commit c35ac68

Browse files
authored
Update features.md with open Fable.Core in code example (#205)
1 parent 6945c03 commit c35ac68

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

docs/docs/javascript/features.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export function hello() {
3636
And this F# code:
3737

3838
```fs
39+
open Fable.Core
40+
3941
[<Import("hello", "./hello.js")>]
4042
let hello : unit -> unit = jsNative
4143
@@ -64,6 +66,8 @@ There are 2 families of imports:
6466
They archieve the same goal, but with a slightly generated code.
6567

6668
```fs
69+
open Fable.Core
70+
6771
[<Import("hello", "./hello.js")>]
6872
let hello : unit -> unit = jsNative
6973
@@ -93,13 +97,17 @@ Some JavaScript optimizations tools can remove the intermediate variable, but no
9397
When trying to bind a global variable, you can use the `[<Global>]` attribute.
9498

9599
```fs
100+
open Fable.Core
101+
96102
[<Global>]
97103
let console: JS.Console = jsNative
98104
```
99105

100106
If 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")>]
104112
let 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")>]
116126
let 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")>]
134146
let 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")>]
144158
let 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")>]
154170
let hello : unit -> unit = jsNative
155171
// Generates: import hello from "./hello.js";

0 commit comments

Comments
 (0)