You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/docs/manual/latest/generate-converters-accessors.mdx
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -298,8 +298,8 @@ As in similar use-cases before, you can also use `@bs.deriving({jsConverter: new
298
298
299
299
## Convert Record Type to Abstract Record
300
300
301
-
> **Note**: For ReScript >= v7, we recommend using [plain records to compile to JS objects](bind-to-js-object#bind-to-record-like-js-objects).
302
-
> This feature might still be useful for certain scenarios, but the ergonomics might be worse
301
+
> **Note**: For ReScript >= v7, we recommend using [plain records to compile to JS objects](bind-to-js-object#bind-to-record-like-js-objects).
302
+
> This feature might still be useful for certain scenarios, but the ergonomics might be worse
303
303
304
304
Use `@bs.deriving(abstract)` on a record type to expand the type into a creation, and a set of getter / setter functions for fields and methods.
305
305
@@ -578,7 +578,7 @@ For example, suppose you need a JavaScript object like this:
578
578
579
579
```js
580
580
var homeRoute = {
581
-
method:"GET",
581
+
type:"GET",
582
582
path:"/",
583
583
action: () =>console.log("Home"),
584
584
// options: ...
@@ -590,7 +590,7 @@ But only the first three fields are required; the options field is optional. You
590
590
```res
591
591
@bs.obj
592
592
external route: (
593
-
~_method: string,
593
+
~\"type": string,
594
594
~path: string,
595
595
~action: list<string> => unit,
596
596
~options: {..}=?,
@@ -600,15 +600,15 @@ external route: (
600
600
601
601
**Note**: the ` = ""` part at the end is just a dummy placeholder, due to syntactic limitations. It serves no purpose currently.
602
602
603
-
This function has four labelled parameters (the fourth one optional), one unlabelled parameter at the end (which we mandate for functions with [optional parameters](function#optional-labeled-arguments), and one parameter (`_method`) that requires an underscore prefix to avoid confusion with the ReScript keyword `method`.
603
+
This function has four labelled parameters (the fourth one optional), one unlabelled parameter at the end (which we mandate for functions with [optional parameters](function#optional-labeled-arguments), and one parameter (`\"type"`) that required quoting to [avoid clashing](use-illegal-identifier-names) with the reserved `type` keyword.
604
604
605
605
Also of interest is the return type: `_`, which tells ReScript to automatically infer the full type of the JS object, sparing you the hassle of writing down the type manually!
0 commit comments