From 20a5adcff16e2842462b9c71281b7c90dca18613 Mon Sep 17 00:00:00 2001 From: chengzhihao Date: Wed, 18 Jun 2025 14:35:00 +0800 Subject: [PATCH] add new type for callback functions Issue: https://gitee.com/openharmony/arkcompiler_runtime_core/issues/ICG1FF Signed-off-by: chengzhihao --- api/@ohos.util.ArrayList.d.ts | 16 ++++++++-------- api/@ohos.util.Deque.d.ts | 8 ++++---- api/@ohos.util.HashMap.d.ts | 2 +- api/@ohos.util.HashSet.d.ts | 2 +- api/@ohos.util.LightWeightMap.d.ts | 2 +- api/@ohos.util.LightWeightSet.d.ts | 2 +- api/@ohos.util.LinkedList.d.ts | 2 +- api/@ohos.util.List.d.ts | 4 ++-- api/@ohos.util.PlainArray.d.ts | 2 +- api/@ohos.util.Queue.d.ts | 2 +- api/@ohos.util.Stack.d.ts | 2 +- api/@ohos.util.TreeMap.d.ts | 4 ++-- api/@ohos.util.TreeSet.d.ts | 4 ++-- api/@ohos.util.d.ets | 9 ++++++--- 14 files changed, 32 insertions(+), 29 deletions(-) diff --git a/api/@ohos.util.ArrayList.d.ts b/api/@ohos.util.ArrayList.d.ts index f8853a1901..a294822a93 100644 --- a/api/@ohos.util.ArrayList.d.ts +++ b/api/@ohos.util.ArrayList.d.ts @@ -484,14 +484,14 @@ declare class ArrayList { /** * Replaces each element of this arrayList with the result of applying the operator to that element. * - * @param { ArrayListCbFn1 } callbackFn - A callback function to execute for each element. + * @param { ArrayListReplaceCb } callbackFn - A callback function to execute for each element. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice * @since 20 * @arkts 1.2 */ - replaceAllElements(callbackFn: ArrayListCbFn1): void; + replaceAllElements(callbackFn: ArrayListReplaceCb): void; /** * Executes a provided function once for each value in the arraylist object. @@ -549,14 +549,14 @@ declare class ArrayList { /** * Iterates over elements in a generic ArrayList and executes a callback function for each element. * - * @param { ArrayListCbFn } callbackFn - A callback function to execute for each element. + * @param { ArrayListForEachCb } callbackFn - A callback function to execute for each element. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice * @since 20 * @arkts 1.2 */ - forEach(callbackFn: ArrayListCbFn): void; + forEach(callbackFn: ArrayListForEachCb): void; /** * Sorts this arraylist according to the order induced by the specified comparator,without comparator this parameter, @@ -958,7 +958,7 @@ declare class ArrayList { /** * The type of ArrayList callback function. * - * @typedef { function } ArrayListCbFn + * @typedef { function } ArrayListForEachCb * @param { T } value - The current element being processed * @param { number } index - The index of the current element * @param { ArrayList } arrlist - The ArrayList instance being traversed @@ -968,12 +968,12 @@ declare class ArrayList { * @since 20 * @arkts 1.2 */ - type ArrayListCbFn = (value: T, index: number, arrlist: ArrayList) => void; + export type ArrayListForEachCb = (value: T, index: number, arrlist: ArrayList) => void; /** * The type of ArrayList callback function. * - * @typedef { function } ArrayListCbFn + * @typedef { function } ArrayListReplaceCb * @param { T } value - The current element being processed * @param { number } index - The index of the current element * @param { ArrayList } arrlist - The ArrayList instance being traversed @@ -983,6 +983,6 @@ declare class ArrayList { * @since 20 * @arkts 1.2 */ - type ArrayListCbFn1 = (value: T, index?: number, arrlist?: ArrayList) => T; + export type ArrayListReplaceCb = (value: T, index: number, arrlist: ArrayList) => T; export default ArrayList; diff --git a/api/@ohos.util.Deque.d.ts b/api/@ohos.util.Deque.d.ts index 8e4758b126..73f2f662e3 100644 --- a/api/@ohos.util.Deque.d.ts +++ b/api/@ohos.util.Deque.d.ts @@ -419,14 +419,14 @@ declare class Deque { /** * Iterates over elements in a generic Deque (double-ended queue) and executes a callback function for each element. * - * @param { DequeCbFnforEach } callbackFn - A callback function to execute for each element. + * @param { DequeForEachCb } callbackFn - A callback function to execute for each element. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice * @since 20 * @arkts 1.2 */ - forEach(callbackFn: DequeCbFnforEach): void; + forEach(callbackFn: DequeForEachCb): void; /** * Returns the byte at the specified index. * @@ -498,7 +498,7 @@ declare class Deque { /** * The type of Deque forEach callback function. * - * @typedef { function } DequeCbFnforEach + * @typedef { function } DequeForEachCb * @param { T } value - The current element being processed * @param { number } index - The index of the current element * @param { Deque } deque - The Deque instance being traversed @@ -508,6 +508,6 @@ declare class Deque { * @since 20 * @arkts 1.2 */ - type DequeCbFnforEach = (value: T, index: number, deque: Deque) => void; + export type DequeForEachCb = (value: T, index: number, deque: Deque) => void; export default Deque; diff --git a/api/@ohos.util.HashMap.d.ts b/api/@ohos.util.HashMap.d.ts index 7ade3272fd..d7d500dc18 100644 --- a/api/@ohos.util.HashMap.d.ts +++ b/api/@ohos.util.HashMap.d.ts @@ -639,6 +639,6 @@ declare class HashMap { * @since 20 * @arkts 1.2 */ - type HashMapCbFn = (value: V, key: K, map: HashMap) => void; + export type HashMapCbFn = (value: V, key: K, map: HashMap) => void; export default HashMap; diff --git a/api/@ohos.util.HashSet.d.ts b/api/@ohos.util.HashSet.d.ts index 654a6e7c8f..6607d94f10 100644 --- a/api/@ohos.util.HashSet.d.ts +++ b/api/@ohos.util.HashSet.d.ts @@ -468,6 +468,6 @@ declare class HashSet { * @since 20 * @arkts 1.2 */ -type HashSetCbFn = (value: T, key: T, set: HashSet) => void; +export type HashSetCbFn = (value: T, key: T, set: HashSet) => void; export default HashSet; diff --git a/api/@ohos.util.LightWeightMap.d.ts b/api/@ohos.util.LightWeightMap.d.ts index b6e9c6823c..3433c11fcc 100644 --- a/api/@ohos.util.LightWeightMap.d.ts +++ b/api/@ohos.util.LightWeightMap.d.ts @@ -983,6 +983,6 @@ declare class LightWeightMap { * @since 20 * @arkts 1.2 */ - type LightWeightMapCbFn = (value: V, key: K, map: LightWeightMap) => void; + export type LightWeightMapCbFn = (value: V, key: K, map: LightWeightMap) => void; export default LightWeightMap; diff --git a/api/@ohos.util.LightWeightSet.d.ts b/api/@ohos.util.LightWeightSet.d.ts index 612b677db1..cd20907d09 100644 --- a/api/@ohos.util.LightWeightSet.d.ts +++ b/api/@ohos.util.LightWeightSet.d.ts @@ -787,6 +787,6 @@ declare class LightWeightSet { * @since 20 * @arkts 1.2 */ -type LightWeightSetForEachCb = (value: T, key: T, set: LightWeightSet) => void +export type LightWeightSetForEachCb = (value: T, key: T, set: LightWeightSet) => void export default LightWeightSet; diff --git a/api/@ohos.util.LinkedList.d.ts b/api/@ohos.util.LinkedList.d.ts index 8e05f21908..33c16b088f 100644 --- a/api/@ohos.util.LinkedList.d.ts +++ b/api/@ohos.util.LinkedList.d.ts @@ -1036,6 +1036,6 @@ declare class LinkedList { * @since 20 * @arkts 1.2 */ -type LinkedListForEachCb = (value: T, index: number, linkedList: LinkedList) => void +export type LinkedListForEachCb = (value: T, index: number, linkedList: LinkedList) => void export default LinkedList; diff --git a/api/@ohos.util.List.d.ts b/api/@ohos.util.List.d.ts index 5967f7ce6c..47f59fa10d 100644 --- a/api/@ohos.util.List.d.ts +++ b/api/@ohos.util.List.d.ts @@ -1029,7 +1029,7 @@ declare class List { * @since 20 * @arkts 1.2 */ -type ListForEachCb = (value: T, index: number, list: List) => void +export type ListForEachCb = (value: T, index: number, list: List) => void /** * The type of List callback function. @@ -1044,6 +1044,6 @@ type ListForEachCb = (value: T, index: number, list: List) => void * @since 20 * @arkts 1.2 */ -type ListReplaceCb = (value: T, index: number, list: List) => T +export type ListReplaceCb = (value: T, index: number, list: List) => T export default List; diff --git a/api/@ohos.util.PlainArray.d.ts b/api/@ohos.util.PlainArray.d.ts index 6b28d6ba11..4e5085753e 100644 --- a/api/@ohos.util.PlainArray.d.ts +++ b/api/@ohos.util.PlainArray.d.ts @@ -838,6 +838,6 @@ declare class PlainArray { * @since 20 * @arkts 1.2 */ -type PlainArrayForEachCb = (value: T, key: number, PlainArray: PlainArray) => void +export type PlainArrayForEachCb = (value: T, key: number, PlainArray: PlainArray) => void export default PlainArray; diff --git a/api/@ohos.util.Queue.d.ts b/api/@ohos.util.Queue.d.ts index abdba11d47..90724be60b 100644 --- a/api/@ohos.util.Queue.d.ts +++ b/api/@ohos.util.Queue.d.ts @@ -349,6 +349,6 @@ declare class Queue { * @since 20 * @arkts 1.2 */ -type QueueForEachCb = (value: T, index: number, queue: Queue) => void +export type QueueForEachCb = (value: T, index: number, queue: Queue) => void export default Queue; diff --git a/api/@ohos.util.Stack.d.ts b/api/@ohos.util.Stack.d.ts index 340ed2c85f..1e76aa0578 100644 --- a/api/@ohos.util.Stack.d.ts +++ b/api/@ohos.util.Stack.d.ts @@ -412,6 +412,6 @@ declare class Stack { * @since 20 * @arkts 1.2 */ -type StackForEachCb = (value: T, index: number, stack: Stack) => void +export type StackForEachCb = (value: T, index: number, stack: Stack) => void export default Stack; diff --git a/api/@ohos.util.TreeMap.d.ts b/api/@ohos.util.TreeMap.d.ts index ad93707e33..abd92fe674 100644 --- a/api/@ohos.util.TreeMap.d.ts +++ b/api/@ohos.util.TreeMap.d.ts @@ -871,7 +871,7 @@ declare class TreeMap { * @since 20 * @arkts 1.2 */ -type TreeMapForEachCb = (value: V, key: K, map: TreeMap) => void +export type TreeMapForEachCb = (value: V, key: K, map: TreeMap) => void /** * The type of TreeMap comparator. @@ -885,6 +885,6 @@ type TreeMapForEachCb = (value: V, key: K, map: TreeMap) => void * @since 20 * @arkts 1.2 */ -type TreeMapComparator = (firstValue: K, secondValue: K) => number +export type TreeMapComparator = (firstValue: K, secondValue: K) => number export default TreeMap; diff --git a/api/@ohos.util.TreeSet.d.ts b/api/@ohos.util.TreeSet.d.ts index d09e7b0548..234c1885de 100644 --- a/api/@ohos.util.TreeSet.d.ts +++ b/api/@ohos.util.TreeSet.d.ts @@ -765,7 +765,7 @@ declare class TreeSet { * @since 20 * @arkts 1.2 */ -type TreeSetForEachCb = (value: T, key: T, set: TreeSet) => void +export type TreeSetForEachCb = (value: T, key: T, set: TreeSet) => void /** * The type of TreeSet comparator. @@ -779,6 +779,6 @@ type TreeSetForEachCb = (value: T, key: T, set: TreeSet) => void * @since 20 * @arkts 1.2 */ -type TreeSetComparator = (firstValue: T, secondValue: T) => number +export type TreeSetComparator = (firstValue: T, secondValue: T) => number export default TreeSet; diff --git a/api/@ohos.util.d.ets b/api/@ohos.util.d.ets index 72a794baa4..cdbc962659 100644 --- a/api/@ohos.util.d.ets +++ b/api/@ohos.util.d.ets @@ -966,7 +966,8 @@ declare namespace util { * Compares two objects for equality. * * @param { Object } obj - An object - * @returns { boolean } Returns true if the given object is the same as the current object; Otherwise, false is returned. + * @returns { boolean } Returns true if the given object is the same as the current object; + * Otherwise, false is returned. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice @@ -1048,7 +1049,8 @@ declare namespace util { /** * Checks whether the current RationalNumber object represents the value 0. * - * @returns { boolean } If the value represented by the current object is 0, true is returned. Otherwise, false is returned. + * @returns { boolean } If the value represented by the current object is 0, true is returned. + * Otherwise, false is returned. * @syscap SystemCapability.Utils.Lang * @crossplatform * @atomicservice @@ -1179,7 +1181,8 @@ declare namespace util { * Check whether the entered value is of arraybuffer type. * * @param { Object } value - A arraybuffer value - * @returns { boolean } Returns true if the value is a built-in ArrayBuffer instance. This does not include SharedArrayBuffer instances. + * @returns { boolean } Returns true if the value is a built-in ArrayBuffer instance. + * This does not include SharedArrayBuffer instances. * Usually, it is desirable to test for both; See isAnyArrayBuffer() for that. * @syscap SystemCapability.Utils.Lang * @crossplatform -- Gitee