diff --git a/CHANGELOG.md b/CHANGELOG.md index 2aba263c97..bced876653 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/runtime/Stdlib_Console.res b/runtime/Stdlib_Console.res index 2c85d0242b..465f520e78 100644 --- a/runtime/Stdlib_Console.res +++ b/runtime/Stdlib_Console.res @@ -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, + 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" diff --git a/runtime/Stdlib_Console.resi b/runtime/Stdlib_Console.resi index ec1d757ab3..5c0f4f8d8d 100644 --- a/runtime/Stdlib_Console.resi +++ b/runtime/Stdlib_Console.resi @@ -244,8 +244,13 @@ Console.debugMany([1, 2, 3]) @variadic external debugMany: array<_> => unit = "console.debug" +type dirOptions = { + colors?: bool, + depth?: Stdlib_Nullable.t, + 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. @@ -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.