Skip to content

Commit d8e87bb

Browse files
docs: improvements to javascript/feature.md for better readability (#212)
Co-authored-by: Amir <[email protected]> Co-authored-by: Maxime Mangel <[email protected]>
1 parent 7255c0b commit d8e87bb

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

docs/docs/javascript/features.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ In this section, we will cover specific features of Fable that are used when int
1111

1212
### `jsNative`
1313

14-
`jsNative` provide a dummy implementation that we use when writing bindings.
14+
`jsNative` provides a dummy implementation that we use when writing bindings.
1515

1616
Here is its definition:
1717

@@ -21,7 +21,7 @@ Here is its definition:
2121
failwith "You've hit dummy code used for Fable bindings. This probably means you're compiling Fable code to .NET by mistake, please check."
2222
```
2323

24-
The thrown exception should never be seen as `jsNative` calls should be replaced by actual JavaScript code calls.
24+
The thrown exception should never be seen as `jsNative` calls, it should be replaced by actual JavaScript code calls.
2525

2626
Examples:
2727

@@ -54,16 +54,16 @@ hello();
5454

5555
## Imports
5656

57-
In JavaScript, the static `import` declaration is used to import codes that are exported by another module.
57+
In JavaScript, the static `import` declaration is used to import code that is exported by another module.
5858

59-
Fable provides different ways to import JavaScript code, to cover different scenarios.
59+
Fable provides different ways to import JavaScript in order to cover different scenarios.
6060

6161
There are 2 families of imports:
6262

6363
- Attribute-based imports
6464
- Function-based imports
6565

66-
They archieve the same goal, but with a slightly generated code.
66+
They achieve the same goal but have differences in the generated code that they produce.
6767

6868
```fs
6969
open Fable.Core
@@ -94,7 +94,7 @@ Some JavaScript optimizations tools can remove the intermediate variable, but no
9494

9595
#### `[<Global>]`
9696

97-
When trying to bind a global variable, you can use the `[<Global>]` attribute.
97+
To bind a global variable, you can use the `[<Global>]` attribute.
9898

9999
```fs
100100
open Fable.Core
@@ -103,7 +103,7 @@ open Fable.Core
103103
let console: JS.Console = jsNative
104104
```
105105

106-
If you want to use a different in you F# code, you can use the `name` parameter:
106+
If you want to use a different name within your F# code you can specify it with the `name` parameter:
107107

108108
```fs
109109
open Fable.Core
@@ -114,7 +114,7 @@ let logger: JS.Console = jsNative
114114

115115
#### `[<Import(...)>]`
116116

117-
This attributes takes two parameters:
117+
This attribute takes two parameters:
118118

119119
- `selector`: the import selector, can be `*`, `default` or a name
120120
- `from`: the path to the JavaScript file / module
@@ -161,7 +161,7 @@ let hello : unit -> unit = jsNative
161161

162162
#### `[<ImportDefault(...)>]`
163163

164-
`ImportDefault` is used to import the default member from a JavaScript module, the name is based on the name of imported module.
164+
`ImportDefault` is used to import the default member from a JavaScript module, the name is based on the name of the imported module.
165165

166166
```fs
167167
open Fable.Core
@@ -244,7 +244,7 @@ let hi : unit -> unit = importMember "./hello.js"
244244

245245
#### `importSideEffects`
246246

247-
`importSideEffects` is used when you wants to import a JavaScript module that has side effects, like a CSS file or a polyfill.
247+
`importSideEffects` is used when you want to import a JavaScript module that has sideeffects, like a CSS file or a polyfill.
248248

249249
```fs
250250
importSideEffects "./style.css"
@@ -258,10 +258,10 @@ importSideEffects "whatwg-fetch"
258258

259259
## Emit, when F# is not enough
260260

261-
Emit is a features offered by Fable, that allows you to write JavaScript code directly in F#.
261+
Emit is a feature offered by Fable, that allows you to write JavaScript code directly in F#.
262262

263263
:::danger
264-
Content of emit snippet, is not validated by F# compiler, so you should use this feature sparingly.
264+
The emit snippet is not validated by the F# compiler so you should use this feature sparingly.
265265
:::
266266

267267
Main use cases:
@@ -483,7 +483,7 @@ Note how Fable replaced the union union type with the underlying type.
483483

484484
#### `U2`, `U3`, ..., `U9`
485485

486-
Fable provides already erased union types, from `U2` to `U9` than you can use without having to define custom erased union each time.
486+
Fable provides already erased union types, from `U2` to `U9` that you can use without having to define custom erased union each time.
487487

488488
```fs
489489
open Fable.Core
@@ -529,7 +529,7 @@ let test(arg: U3<string, int, float[]>) =
529529

530530
### Erased types
531531

532-
Decoring a type with `[<Erase>]` allows you to instruct Fable to not generate any code for that type. This is useful when you want to use a type from a JS library that you don't want to generate bindings for.
532+
Decorating a type with `[<Erase>]` allows you to instruct Fable to not generate any code for that type. This is useful when you want to use a type from a JS library that you don't want to generate bindings for.
533533

534534
```fs
535535
open Fable.Core
@@ -592,7 +592,7 @@ import { Avatar } from "./user.jsx";
592592
export const x = Avatar("123");
593593
```
594594

595-
The generated code is much smaller and doesn't include any reflection information. This trick is useful when you want to minimize the size of your bundle, this is the trick used by [Feliz ecosystem](https://github.com/Zaid-Ajaj/Feliz/) to generate React code that is almost as small as if you were writing it by hand in JavaScript.
595+
The generated code is much smaller and doesn't include any reflection information. This trick is useful when you want to minimize the size of your bundle, this is the trick used by the [Feliz ecosystem](https://github.com/Zaid-Ajaj/Feliz/) to generate React code that is almost as small as if you were writing it by hand in JavaScript.
596596

597597
## `[<StringEnum>]`
598598

@@ -615,7 +615,7 @@ function on(event, callback) {
615615
Fable supports this feature by using union types and `StringEnum` attributes.
616616

617617
:::info
618-
These union types must not have any data fields as they will be compiled to a string matching the name of the union case.
618+
These union types should not have any data fields as they will be compiled to a string which matches the name of the union case.
619619
:::
620620

621621
```fs
@@ -644,7 +644,7 @@ event("click", () => {
644644

645645
### `CaseRules`
646646

647-
`StringEnum` accept a parameters allowing you to control the casing used to conver the union case name to a string.
647+
`StringEnum` accepts parameters which allow you to control the casing used to convert the union case name to a string.
648648

649649
- `CaseRules.None`: `MouseOver` becomes `MouseOver`
650650
- `CaseRules.LowerFirst`: `MouseOver` becomes `mouseOver`
@@ -663,9 +663,9 @@ open Fable.Core
663663
664664
[<StringEnum>]
665665
type EventType =
666-
| [<CompiledName("Abracadabra")>] MouveOver
666+
| [<CompiledName("Abracadabra")>] MouseOver
667667
668-
let eventType = EventType.MouveOver
668+
let eventType = EventType.MouseOver
669669
```
670670

671671
generates
@@ -676,7 +676,7 @@ export const eventType = "Abracadabra";
676676

677677
## Plain Old JavaScript Objects
678678

679-
POJO (Plain Old JavaScript Objects) are one of the most common types in JavaScript.
679+
POJO (Plain Old JavaScript Objects) is one of the most common types in JavaScript.
680680

681681
```js
682682
export const user = {
@@ -687,11 +687,11 @@ export const user = {
687687

688688
Fable offers several ways to work with POJOs.
689689

690-
The recommended way to work with POJOs is to use `[<ParamObject>]` as they are the closest to normal F# classes. But we are going to explore all the options from the simpler to put in practice to the more verbose.
690+
The recommended way to work with POJOs is to use `[<ParamObject>]` as they are the closest to normal F# classes. But we will explore all the potential options, from the simplest to the more verbose.
691691

692692
### Anonymous records
693693

694-
Fable translates anonymous records to POJOs, making them perfect one of the simplest ways to work with POJOs.
694+
Fable translates anonymous records to POJOs, making them perfect as one of the simplest ways to work with POJOs.
695695

696696
```fs
697697
let user =
@@ -767,7 +767,7 @@ user.Age = 20;
767767

768768
### `jsOptions`
769769

770-
`jsOptions` is a function that gives you access to an objet of the provided type and allows you to set the fields.
770+
`jsOptions` is a function that gives you access to an object of the provided type and allows you to set the fields.
771771

772772
```fs
773773
open Fable.Core
@@ -850,7 +850,7 @@ options2.isCaseSensitive
850850

851851
#### Optional properties
852852

853-
When a property is option, the argument in the method is of the form `?<arg name>: <type>` and the getter/setter is of the form `<arg name>: <type> option`.
853+
When a property is an `option`, the argument in the method is of the form `?<arg name>: <type>` and the getter/setter is of the form `<arg name>: <type> option`.
854854

855855
```fs
856856
[<AllowNullLiteral>]
@@ -1056,7 +1056,7 @@ Note how each method has a different name in JavaScript.
10561056

10571057
### `[<AttachMembers>]`
10581058

1059-
If you want to have all members attached to a class (as in standard JS classes) and not-mangled use the `AttachMembers` attribute. But be aware overloads won't work in this case.
1059+
If you want to have all members attached to a class (as in standard JS classes) and not-mangled, use the `AttachMembers` attribute. But be aware overloads won't work in this case.
10601060

10611061
<p class="tag is-info is-medium">
10621062
Added in v3.2.2
@@ -1214,7 +1214,7 @@ Dynamic typing allows you to access an object property by name
12141214
:::danger
12151215
This feature is not type-safe and should be used with caution.
12161216

1217-
Adocate use case for this feature is when you are prototyping or don't have the time to write a proper type-safe interop.
1217+
The use case for this feature is when you are prototyping or don't have the time to write a proper type-safe interop.
12181218
:::
12191219

12201220
### Property access

0 commit comments

Comments
 (0)