Skip to content

Commit 6f799bc

Browse files
authored
Add optional ~options argument to Console.dir (#7504)
* Add optional `~options` argument to Console.dir * Add CHANGELOG * Format files
1 parent 021682a commit 6f799bc

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
- Add `RegExp.flags`. https://github.com/rescript-lang/rescript/pull/7461
1818
- Add `Array.findLast`, `Array.findLastWithIndex`, `Array.findLastIndex`, `Array.findLastIndexWithIndex` and `Array.findLastIndexOpt`. https://github.com/rescript-lang/rescript/pull/7503
19+
- Add `options` argument to `Console.dir`. https://github.com/rescript-lang/rescript/pull/7504
1920

2021
#### :bug: Bug fix
2122

runtime/Stdlib_Console.res

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@
1919
@val external debug6: ('a, 'b, 'c, 'd, 'e, 'f) => unit = "console.debug"
2020
@val @variadic external debugMany: array<_> => unit = "console.debug"
2121

22-
@val external dir: 'a => unit = "console.dir"
22+
type dirOptions = {
23+
colors?: bool,
24+
depth?: Stdlib_Nullable.t<int>,
25+
showHidden?: bool,
26+
}
27+
@val external dir: ('a, ~options: dirOptions=?) => unit = "console.dir"
2328
@val external dirxml: 'a => unit = "console.dirxml"
2429

2530
@val external error: 'a => unit = "console.error"

runtime/Stdlib_Console.resi

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,13 @@ Console.debugMany([1, 2, 3])
244244
@variadic
245245
external debugMany: array<_> => unit = "console.debug"
246246

247+
type dirOptions = {
248+
colors?: bool,
249+
depth?: Stdlib_Nullable.t<int>,
250+
showHidden?: bool,
251+
}
247252
/**
248-
`dir(object)` displays an interactive view of the object in the console.
253+
`dir(object, options)` displays an interactive view of the object in the console.
249254

250255
See [`console.dir`](https://developer.mozilla.org/en-US/docs/Web/API/console/dir)
251256
on MDN.
@@ -254,10 +259,11 @@ on MDN.
254259

255260
```rescript
256261
Console.dir({"language": "rescript", "version": "10.1.2"})
262+
Console.dir({"language": "rescript", "version": {"major": "10", "minor": "1", "patch": "2"}}, ~options={depth: null})
257263
```
258264
*/
259265
@val
260-
external dir: 'a => unit = "console.dir"
266+
external dir: ('a, ~options: dirOptions=?) => unit = "console.dir"
261267

262268
/**
263269
`dirxml(object)` displays an interactive tree view of an XML/HTML element in the console.

0 commit comments

Comments
 (0)