Skip to content

Add optional ~options argument to Console.dir #7504

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

Merged
merged 4 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

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

#### :bug: Bug fix

Expand Down
7 changes: 6 additions & 1 deletion runtime/Stdlib_Console.res
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
@val external debug6: ('a, 'b, 'c, 'd, 'e, 'f) => unit = "console.debug"
@val @variadic external debugMany: array<_> => unit = "console.debug"

@val external dir: 'a => unit = "console.dir"
type dirOptions = {
colors?: bool,
depth?: Stdlib_Nullable.t<int>,
showHidden?: bool,
}
@val external dir: ('a, ~options: dirOptions=?) => unit = "console.dir"
@val external dirxml: 'a => unit = "console.dirxml"

@val external error: 'a => unit = "console.error"
Expand Down
10 changes: 8 additions & 2 deletions runtime/Stdlib_Console.resi
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,13 @@ Console.debugMany([1, 2, 3])
@variadic
external debugMany: array<_> => unit = "console.debug"

type dirOptions = {
colors?: bool,
depth?: Stdlib_Nullable.t<int>,
showHidden?: bool,
}
/**
`dir(object)` displays an interactive view of the object in the console.
`dir(object, options)` displays an interactive view of the object in the console.

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

```rescript
Console.dir({"language": "rescript", "version": "10.1.2"})
Console.dir({"language": "rescript", "version": {"major": "10", "minor": "1", "patch": "2"}}, ~options={depth: null})
```
*/
@val
external dir: 'a => unit = "console.dir"
external dir: ('a, ~options: dirOptions=?) => unit = "console.dir"

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