This is an automated email from the ASF dual-hosted git repository.

kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-js.git


The following commit(s) were added to refs/heads/main by this push:
     new 6ee064e  fix: Resolve TS2352 type error in MapBuilder for TypeScript 
5.6+ (#373)
6ee064e is described below

commit 6ee064e5a13559f8798b2e41ed4e28b79271749f
Author: Divyanshu Singh <[email protected]>
AuthorDate: Wed Feb 4 06:06:19 2026 +0530

    fix: Resolve TS2352 type error in MapBuilder for TypeScript 5.6+ (#373)
    
    ## What's Changed
    
    Fixed TS2352 type conversion error in MapBuilder.setValue() that occurs
    with TypeScript 5.6+ due to stricter type checking.
    
    Changes
    
    Updated type assertion in [map.ts] to use intermediate unknown cast (as
    unknown as MapValue<K, V>) to satisfy TypeScript 5.6+ stricter type
    narrowing
    Removed unnecessary type assertion on pending.get(index) since the type
    is already inferred correctly
    
    Why
    TypeScript 5.6 introduced stricter type conversion rules, causing TS2352
    errors when directly casting between incompatible types. The as unknown
    as T pattern is the recommended approach for these scenarios.
    
    This is a non-breaking change - it only affects compile-time behavior
    and has no runtime impact.
    
    Closes #49 .
    
    Co-authored-by: Divyanshu singh <[email protected]>
---
 src/builder/map.ts | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/builder/map.ts b/src/builder/map.ts
index 4c73c4f..3ba2d44 100644
--- a/src/builder/map.ts
+++ b/src/builder/map.ts
@@ -32,9 +32,9 @@ export class MapBuilder<K extends DataType = any, V extends 
DataType = any, TNul
     }
 
     public setValue(index: number, value: MapValueExt<K, V>) {
-        const row = (value instanceof Map ? value : new 
Map(Object.entries(value))) as MapValue<K, V>;
+        const row = (value instanceof Map ? value : new 
Map(Object.entries(value))) as unknown as MapValue<K, V>;
         const pending = this._pending || (this._pending = new Map() as 
MapValues<K, V>);
-        const current = pending.get(index) as Map<K, V> | undefined;
+        const current = pending.get(index);
         current && (this._pendingLength -= current.size);
         this._pendingLength += row.size;
         pending.set(index, row);

Reply via email to