From 0b78f079d7d7f00dcd7a4098d2b0cbbf40a528bd Mon Sep 17 00:00:00 2001 From: Keeno Lee Date: Tue, 22 Apr 2025 16:38:40 +0800 Subject: [PATCH 1/2] docs: clarify map(parseInt) example with explicit radix Use an arrow-function callback to explicitly forward only the string and a radix of 10 to parseInt: ```js // GOOD: we only forward the string (and an explicit radix) ['11','5','3'].map(n => parseInt(n, 10)); // [11, 5, 3] --- tsguide.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tsguide.html b/tsguide.html index d96372f03..a45cd2b5a 100644 --- a/tsguide.html +++ b/tsguide.html @@ -1561,8 +1561,8 @@

Prefer passing arrow functions

Instead, prefer passing an arrow-function that explicitly forwards parameters to the named callback.

-
// GOOD: Arguments are explicitly passed to the callback
-const numbers = ['11', '5', '3'].map((n) => parseInt(n));
+
// GOOD: we only forward the string (and an explicit radix)
+const numbers = ['11', '5', '3'].map((n) => parseInt(n,10));
 // > [11, 5, 3]
 
 // GOOD: Function is locally defined and is designed to be used as a callback

From 8d0c19fcf0952bd92934fc16fd3dd6cd8ac8e627 Mon Sep 17 00:00:00 2001
From: Keeno Lee 
Date: Fri, 25 Apr 2025 02:52:09 +0800
Subject: [PATCH 2/2] docs: simplify GOOD callback comment
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Shorten the “GOOD” example comment to its original concise form, per maintainer feedback:
---
 tsguide.html | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tsguide.html b/tsguide.html
index a45cd2b5a..3d1046fb0 100644
--- a/tsguide.html
+++ b/tsguide.html
@@ -1561,8 +1561,8 @@ 

Prefer passing arrow functions

Instead, prefer passing an arrow-function that explicitly forwards parameters to the named callback.

-
// GOOD: we only forward the string (and an explicit radix)
-const numbers = ['11', '5', '3'].map((n) => parseInt(n,10));
+
// GOOD: Arguments are explicitly passed to the callback
+const numbers = ['11', '5', '3'].map((n) => parseInt(n, 10));
 // > [11, 5, 3]
 
 // GOOD: Function is locally defined and is designed to be used as a callback