From 0e605e0936535d143e4100abba81d482b0ef119d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Thu, 22 May 2025 19:30:54 +0100 Subject: [PATCH 1/3] Add optional `~options` argument to Console.dir --- runtime/Stdlib_Console.res | 7 ++++++- runtime/Stdlib_Console.resi | 10 ++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/runtime/Stdlib_Console.res b/runtime/Stdlib_Console.res index 2c85d0242b..78bc5ddefd 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..521487a821 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. From bf39521c67f25b845e529d4e28b777e6ba3b6424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Thu, 22 May 2025 19:32:14 +0100 Subject: [PATCH 2/3] Add CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b44e383e83..5b5b2af6dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ #### :rocket: New Feature - Add `RegExp.flags`. https://github.com/rescript-lang/rescript/pull/7461 +- Add `options` argument to `Console.dir`. https://github.com/rescript-lang/rescript/pull/7504 #### :bug: Bug fix From 8b7676df54c0b8c6694aebbe4772ebc2d1442112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Thu, 22 May 2025 20:05:27 +0100 Subject: [PATCH 3/3] Format files --- runtime/Stdlib_Console.res | 2 +- runtime/Stdlib_Console.resi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/Stdlib_Console.res b/runtime/Stdlib_Console.res index 78bc5ddefd..465f520e78 100644 --- a/runtime/Stdlib_Console.res +++ b/runtime/Stdlib_Console.res @@ -22,7 +22,7 @@ type dirOptions = { colors?: bool, depth?: Stdlib_Nullable.t, - showHidden?: bool + showHidden?: bool, } @val external dir: ('a, ~options: dirOptions=?) => unit = "console.dir" @val external dirxml: 'a => unit = "console.dirxml" diff --git a/runtime/Stdlib_Console.resi b/runtime/Stdlib_Console.resi index 521487a821..5c0f4f8d8d 100644 --- a/runtime/Stdlib_Console.resi +++ b/runtime/Stdlib_Console.resi @@ -247,7 +247,7 @@ external debugMany: array<_> => unit = "console.debug" type dirOptions = { colors?: bool, depth?: Stdlib_Nullable.t, - showHidden?: bool + showHidden?: bool, } /** `dir(object, options)` displays an interactive view of the object in the console.