Skip to content

Commit 86dc63a

Browse files
authored
Merge pull request #9 from rescript-lang/add-namespace
Add namespace
2 parents 9c5dbbb + 60c22f9 commit 86dc63a

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

docs/content/docs/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const rescriptJson = `
3636
"@rescript/webapi",
3737
],
3838
"bsc-flags": [
39-
"-open Global"
39+
"-open WebAPI.Global"
4040
]
4141
}
4242
`;
@@ -48,7 +48,7 @@ export const rescriptJson = `
4848
After installing the package , you can use bindings for the various Web APIs as defined in [MDN](https://developer.mozilla.org/en-US/docs/Web/API).
4949

5050
export const rescriptSample = `
51-
// Note that this only works when you added the \`-open Global\` bsc flag.
51+
// Note that this only works when you added the \`-open WebAPI.Global\` bsc flag.
5252
let location = window.location
5353
5454
// Access properties using \`.\`

docs/content/docs/philosophy.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ In other words, if you are searching for a specific JavaScript binding, begin yo
1818
Each API will have its interface and auxiliary types in a module named after the API, suffixed with `API` to prevent collisions with the type module.
1919

2020
```ReScript
21-
open Global
22-
open DOMAPI
21+
open WebAPI.Global
22+
open WebAPI.DOMAPI
2323
2424
let myElement: element = document->Document.createElement( ~localName = "div")
2525
```
@@ -43,13 +43,17 @@ JavaScript supports function overloads, where a function can have multiple signa
4343
In some cases, type conversion will be required. Subtypes can safely be cast to their base type using conversion helpers within their module.
4444

4545
```ReScript
46+
open WebAPI
47+
4648
let element: element = document->Document.createElement( ~localName = "div")
4749
let node: node = element->Element.asNode
4850
```
4951

5052
Any other conversions can be performed using the `Prelude.unsafeConversation` helper. This should be done with caution, as it can lead to runtime errors.
5153

5254
```ReScript
55+
open WebAPI
56+
5357
let element: element = document->Document.createElement( ~localName = "div")
5458
// This is potentially unsafe, as the type system cannot guarantee the conversion
5559
let divElement: htmlDivElement = element->Prelude.unsafeConversation

rescript.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"version": "0.0.0",
33
"name": "@rescript/webapi",
4+
"namespace": "WebAPI",
45
"sources": [
56
{
67
"dir": "src",

0 commit comments

Comments
 (0)