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/module.mdx
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -140,6 +140,23 @@ var p = School.getProfession(School.person1);
140
140
141
141
</CodeTab>
142
142
143
+
### Use `open!` to ignore shadow warnings
144
+
145
+
There are situations where `open` will cause a warning due to existing identifiers (bindings, types) being redefined. Use `open!` to explicitly tell the compiler that this is desired behavior.
146
+
147
+
```res
148
+
let map = (arr, value) => {
149
+
value
150
+
}
151
+
152
+
// opening Js.Array2 would shadow our previously defined `map`
153
+
// `open!` will explicitly turn off the automatic warning
154
+
open! Js.Array2
155
+
let arr = map([1,2,3], (a) => { a + 1})
156
+
```
157
+
158
+
**Note:** Same as with `open`, don't overuse `open!` statements if not necessary. Use (sub)modules to prevent shadowing issues.
159
+
143
160
### Extending modules
144
161
145
162
Using `include` in a module statically "spreads" a module's content into a new one, thus often fulfill the role of "inheritance" or "mixin".
0 commit comments