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
Add "Import a JSON file content" to "Import From JavaScript" page #200
base: master
Are you sure you want to change the base?
Conversation
Could be handy for new comers or eternal newbies like me.
<CodeTab labels={["ReScript", "JS Output"]}> | ||
|
||
```res example | ||
type dataType |
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.
What do you think about making this a Json type type dataType = Js.Json.t
?
@@ -70,6 +70,25 @@ console.log(Student.default); | |||
|
|||
</CodeTab> | |||
|
|||
### Import a JSON file content | |||
|
|||
Use the `bs.module` [external](external.md): |
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.
Very minor: Since the bs.module and link is mentioned earlier in the page, what do you think about replacing this with a simple sentence such as "ReScript also provides built in support for reading JSON files." (similar to the couple of previous examples).
I think this particular example is too concrete. Import / Export talks about how to interop with different module kinds. |
Yeah maybe. Also my example is incomplete as it's not the same thing that's need to be written depending on you @bs.module external studentNames: dataType = "./students.json" That's for commonjs. For @bs.module("./students.json") external studentNames: dataType = "default" Anyway this definitely needs to be somewhere in the doc. I am doing ReScript/Reason for while now (not 100% of my weeks but still) and I always find my self to check doc for this to not have to think about it. |
Alriiight, I think we want to have this in, but the PR is a little outdated. Will copy over the changes and do some adaptions! |
Could be handy for new comers or eternal newbies like me.