Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MoOx
Copy link
Contributor

@MoOx MoOx commented Jan 17, 2021

Could be handy for new comers or eternal newbies like me.

Could be handy for new comers or eternal newbies like me.
<CodeTab labels={["ReScript", "JS Output"]}>

```res example
type dataType
Copy link
Contributor

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):
Copy link
Contributor

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).

@ryyppy
Copy link
Member

ryyppy commented Jan 25, 2021

I think this particular example is too concrete. Import / Export talks about how to interop with different module kinds.
Maybe it would be better to put that in the Cheatsheet in the JS Module Interop section instead?

@MoOx
Copy link
Contributor Author

MoOx commented Jan 25, 2021

Yeah maybe. Also my example is incomplete as it's not the same thing that's need to be written depending on you package-specs.module value (es6 or commonjs)
I wrote

@bs.module external studentNames: dataType = "./students.json"

That's for commonjs.

For es6 you need to write

@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.

@ryyppy
Copy link
Member

ryyppy commented Sep 8, 2021

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants