From 86623b4719a3d1b3309ee2a4c339a64b4213ccb8 Mon Sep 17 00:00:00 2001 From: hemanth Date: Mon, 20 Jul 2026 23:23:27 -0700 Subject: [PATCH] repl: add function signature hints When typing a function name followed by '(', the REPL now displays a dimmed hint below the input line showing the function's parameters. For example, typing 'console.log(' shows: // console.log(...data) Uses the inspector to safely extract parameter lists via Function.prototype.toString(), with throwOnSideEffect to prevent unintended evaluation. PR-URL: https://github.com/nodejs/node/pull/64610 --- doc/api/repl.md | 16 +- lib/internal/repl/utils.js | 126 +++++++++++++++ lib/repl.js | 15 ++ test/parallel/test-repl-signature-hints.js | 175 +++++++++++++++++++++ 4 files changed, 331 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-repl-signature-hints.js diff --git a/doc/api/repl.md b/doc/api/repl.md index c384ebf1391303..ade84ab1cca990 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -27,7 +27,8 @@ result. Input and output may be from `stdin` and `stdout`, respectively, or may be connected to any Node.js [stream][]. Instances of [`repl.REPLServer`][] support automatic completion of inputs, -completion preview, simplistic Emacs-style line editing, multi-line inputs, +completion preview, function signature hints, simplistic Emacs-style line editing, +multi-line inputs, [ZSH][]-like reverse-i-search, [ZSH][]-like substring-based history search, ANSI-styled output, saving and restoring current REPL session state, error recovery, and customizable evaluation functions. Terminals that do not support @@ -232,6 +233,19 @@ undefined undefined ``` +### Function signature hints + +The REPL provides a visual hint of a function's parameters when typing its +name followed by an open parenthesis `(`. This hint is displayed below the +input line. + +```console +> console.log( +// console.log(...data) +``` + +Requires the `preview` feature to be enabled and the inspector to be available. + ### Reverse-i-search