-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix JS output in 'Working with JavaScript objects and values' page #212
base: master
Are you sure you want to change the base?
Conversation
c273e71
to
486c3f9
Compare
486c3f9
to
98722f8
Compare
…ects when in reasonml mode
@@ -202,7 +202,7 @@ manual](https://v2.ocaml.org/manual/objectexamples.html). | |||
We have already explored one approach for creating JavaScript object literals by | |||
using [`Js.t` values and the `mel.obj` extension](#using-js-t-objects). | |||
|
|||
Melange additionally offers the `@mel.obj` attribute, which can be used in | |||
Melange additionally offers the `mel.obj` attribute, which can be used in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the @
from attribute names that was added in previous PR.
position. Not having the last param `unit` would lead to a warning, which is | ||
explained in detail [in the OCaml | ||
documentation](https://ocaml.org/docs/labels#warning-this-optional-argument-cannot-be-erased). | ||
> **Note**: in this particular case, a final param of type unit, `()` must be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jchavarri I wonder if we can migrate to new syntax for custom containers in vitepress? They are more pleasant to edit, but they do have different styling than this old syntax.
@@ -1076,20 +1075,20 @@ not prevent consumers of the external function from calling it using values that | |||
are unsupported by the JavaScript function. Let’s see how we can use polymorphic | |||
variants to avoid runtime errors. | |||
|
|||
If the values are strings, we can use the `mel.string` attribute: | |||
If the values are strings, we can directly use polymorphic variants: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this because Melange compiler now generates warning if you try to use mel.string
in this way
used, and the `##` infix operator allows to read from the object properties: | ||
the properties inside them. | ||
|
||
- To create values, use the <span class="text-ocaml">`[%mel.obj]` extension |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added reasonml-specific text since formatting let john = [%mel.obj { name : "john", age : 99 }];
in Reason syntax will convert it to just let john = { "name": "john", "age": 99 }
I fixed some typos and mistakes on the 'Working with JavaScript objects and values' page, and in the process converted all the JS output from commonjs to es6 (since I used Melange Playground to generate the snippets and all JS output there is es6 now).