Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AOT] add type for AOT engine #15527

Merged
merged 9 commits into from
Jun 28, 2023
Merged

[AOT] add type for AOT engine #15527

merged 9 commits into from
Jun 28, 2023

Conversation

PPpro
Copy link
Contributor

@PPpro PPpro commented Jun 25, 2023

Re: https://github.com/cocos/3d-tasks/issues/16413

Changelog


Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

@PPpro PPpro changed the base branch from develop to v3.8.1 June 25, 2023 10:40
@PPpro PPpro requested a review from minggo June 25, 2023 10:40
@PPpro PPpro marked this pull request as draft June 25, 2023 11:01
@PPpro PPpro marked this pull request as ready for review June 27, 2023 05:13
@github-actions
Copy link

github-actions bot commented Jun 27, 2023

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -16815,21 +16815,21 @@
             multiply(other: Color): Color;
             /**
              * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
              */
-            _set_r_unsafe(red: any): Color;
+            _set_r_unsafe(red: number): Color;
             /**
              * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
              */
-            _set_g_unsafe(green: any): Color;
+            _set_g_unsafe(green: number): Color;
             /**
              * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
              */
-            _set_b_unsafe(blue: any): Color;
+            _set_b_unsafe(blue: number): Color;
             /**
              * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
              */
-            _set_a_unsafe(alpha: any): Color;
+            _set_a_unsafe(alpha: number): Color;
         }
         export function color(other: Color | string): Color;
         export function color(r?: number, g?: number, b?: number, a?: number): Color;
         /**
@@ -22502,9 +22502,9 @@
         number
     ];
     export function setPropertyEnumType(objectOrConstructor: object, propertyName: string, enumType: __private._cocos_core_value_types_enum__EnumType): void;
     export function setPropertyEnumTypeOnAttrs(attrs: Record<string, any>, propertyName: string, enumType: __private._cocos_core_value_types_enum__EnumType): void;
-    export function isCCObject(object: any): boolean;
+    export function isCCObject(object: any): object is CCObject;
     export function isValid(value: any, strictMode?: boolean): boolean;
     export function createDefaultPipeline(): ForwardPipeline;
     export namespace pipeline {
         export enum SetIndex {
@@ -23718,9 +23718,9 @@
          * @readonly
          *
          * @deprecated since v3.4.0
          */
-        get eventProcessor(): any;
+        get eventProcessor(): __private._cocos_scene_graph_node_event_processor__NodeEventProcessor;
         /**
          * @internal
          */
         protected static idGenerator: js.IDGenerator;
@@ -23755,9 +23755,9 @@
         protected _scene: Scene;
         protected _activeInHierarchy: boolean;
         protected _id: string;
         protected _name: string;
-        protected _eventProcessor: any;
+        protected _eventProcessor: __private._cocos_scene_graph_node_event_processor__NodeEventProcessor;
         protected _eventMask: number;
         protected _siblingIndex: number;
         /**
          * @en
@@ -61682,8 +61682,347 @@
             TRT = 15,
             TT = 16,
             MAX_BIT_COUNT = 17
         }
+        export enum _cocos_scene_graph_node_event_processor__DispatcherEventType {
+            ADD_POINTER_EVENT_PROCESSOR = 0,
+            REMOVE_POINTER_EVENT_PROCESSOR = 1,
+            MARK_LIST_DIRTY = 2
+        }
+        /// <reference types="./@types/globals" />
+        export class _cocos_core_event_callbacks_invoker__CallbackInfo {
+            callback: _types_globals__AnyFunction;
+            target: unknown | undefined;
+            once: boolean;
+            set(callback: _types_globals__AnyFunction, target?: unknown, once?: boolean): void;
+            reset(): void;
+            check(): boolean;
+        }
+        /**
+         * @zh 事件监听器列表的简单封装。
+         * @en A simple list of event callbacks
+         */
+        export class _cocos_core_event_callbacks_invoker__CallbackList {
+            callbackInfos: Array<_cocos_core_event_callbacks_invoker__CallbackInfo | null>;
+            isInvoking: boolean;
+            containCanceled: boolean;
+            /**
+             * @zh 从列表中移除与指定目标相同回调函数的事件。
+             * @en Remove the event listeners with the given callback from the list
+             *
+             * @param cb - The callback to be removed
+             */
+            removeByCallback(cb: _types_globals__AnyFunction): void;
+            /**
+             * @zh 从列表中移除与指定目标相同调用者的事件。
+             * @en Remove the event listeners with the given target from the list
+             * @param target
+             */
+            removeByTarget(target: unknown): void;
+            /**
+             * @zh 移除指定编号事件。
+             * @en Remove the event listener at the given index
+             * @param index
+             */
+            cancel(index: number): void;
+            /**
+             * @zh 注销所有事件。
+             * @en Cancel all event listeners
+             */
+            cancelAll(): void;
+            /**
+             * @zh 立即删除所有取消的回调。(在移除过程中会更加紧凑的排列数组)
+             * @en Delete all canceled callbacks and compact array
+             */
+            purgeCanceled(): void;
+            /**
+             * @zh 清除并重置所有数据。
+             * @en Clear all data
+             */
+            clear(): void;
+        }
+        export interface _cocos_core_event_callbacks_invoker__ICallbackTable {
+            [x: string]: _cocos_core_event_callbacks_invoker__CallbackList | undefined;
+        }
+        export type _cocos_core_event_callbacks_invoker__EventType = string | number;
+        /**
+         * @zh CallbacksInvoker 用来根据事件名(Key)管理事件监听器列表并调用回调方法。
+         * @en CallbacksInvoker is used to manager and invoke event listeners with different event keys,
+         * each key is mapped to a CallbackList.
+         * @engineInternal
+         */
+        export class _cocos_core_event_callbacks_invoker__CallbacksInvoker<EventTypeClass extends _cocos_core_event_callbacks_invoker__EventType = _cocos_core_event_callbacks_invoker__EventType> {
+            /**
+             * @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
+             */
+            _callbackTable: _cocos_core_event_callbacks_invoker__ICallbackTable;
+            /**
+             * @zh 向一个事件名注册一个新的事件监听器,包含回调函数和调用者
+             * @en Register an event listener to a given event key with callback and target.
+             *
+             * @param key - Event type
+             * @param callback - Callback function when event triggered
+             * @param target - Callback callee
+             * @param once - Whether invoke the callback only once (and remove it)
+             */
+            on(key: EventTypeClass, callback: _types_globals__AnyFunction, target?: unknown, once?: boolean): _types_globals__AnyFunction;
+            /**
+             * @zh 检查指定事件是否已注册回调。
+             * @en Checks whether there is correspond event listener registered on the given event
+             * @param key - Event type
+             * @param callback - Callback function when event triggered
+             * @param target - Callback callee
+             */
+            hasEventListener(key: EventTypeClass, callback?: _types_globals__AnyFunction, target?: unknown): boolean;
+            /**
+             * @zh 移除在特定事件类型中注册的所有回调或在某个目标中注册的所有回调。
+             * @en Removes all callbacks registered in a certain event type or all callbacks registered with a certain target
+             * @param keyOrTarget - The event type or target with which the listeners will be removed
+             */
+            removeAll(keyOrTarget: EventTypeClass | unknown): void;
+            /**
+             * @zh 删除以指定事件,回调函数,目标注册的回调。
+             * @en Remove event listeners registered with the given event key, callback and target
+             * @param key - Event type
+             * @param callback - The callback function of the event listener, if absent all event listeners for the given type will be removed
+             * @param target - The callback callee of the event listener
+             */
+            off(key: EventTypeClass, callback?: _types_globals__AnyFunction, target?: unknown): void;
+            /**
+             * @zh 派发一个指定事件,并传递需要的参数
+             * @en Trigger an event directly with the event name and necessary arguments.
+             * @param key - event type
+             * @param arg0 - The first argument to be passed to the callback
+             * @param arg1 - The second argument to be passed to the callback
+             * @param arg2 - The third argument to be passed to the callback
+             * @param arg3 - The fourth argument to be passed to the callback
+             * @param arg4 - The fifth argument to be passed to the callback
+             */
+            emit(key: EventTypeClass, arg0?: any, arg1?: any, arg2?: any, arg3?: any, arg4?: any): void;
+            /**
+             * 移除所有回调。
+             */
+            clear(): void;
+        }
+        export interface _cocos_scene_graph_node_event_processor__IMask {
+            index: number;
+            comp: Component;
+        }
+        /**
+         * @en The input event type
+         * @zh 输入事件类型
+         */
+        export enum _cocos_input_types_event_enum__InputEventType {
+            /**
+             * @en
+             * The event type for touch start event
+             *
+             * @zh
+             * 手指开始触摸事件。
+             */
+            TOUCH_START = "touch-start",
+            /**
+             * @en
+             * The event type for touch move event
+             *
+             * @zh
+             * 当手指在屏幕上移动时。
+             */
+            TOUCH_MOVE = "touch-move",
+            /**
+             * @en
+             * The event type for touch end event
+             *
+             * @zh
+             * 手指结束触摸事件。
+             */
+            TOUCH_END = "touch-end",
+            /**
+             * @en
+             * The event type for touch end event
+             *
+             * @zh
+             * 当手指在目标节点区域外离开屏幕时。
+             */
+            TOUCH_CANCEL = "touch-cancel",
+            /**
+             * @en
+             * The event type for mouse down events
+             *
+             * @zh
+             * 当鼠标按下时触发一次。
+             */
+            MOUSE_DOWN = "mouse-down",
+            /**
+             * @en
+             * The event type for mouse move events
+             *
+             * @zh
+             * 当鼠标在目标节点在目标节点区域中移动时,不论是否按下。
+             */
+            MOUSE_MOVE = "mouse-move",
+            /**
+             * @en
+             * The event type for mouse up events
+             *
+             * @zh
+             * 当鼠标从按下状态松开时触发一次。
+             */
+            MOUSE_UP = "mouse-up",
+            /**
+             * @en
+             * The event type for mouse wheel events
+             *
+             * @zh 手指开始触摸事件
+             */
+            MOUSE_WHEEL = "mouse-wheel",
+            /**
+             * @en The event type for the key down event
+             * @zh 当按下按键时触发的事件
+             */
+            KEY_DOWN = "keydown",
+            /**
+             * @en The event type for the key pressing event, the event will be continuously dispatched in the key pressed state
+             * @zh 当按着按键时触发的事件, 该事件在按下状态会持续派发
+             */
+            KEY_PRESSING = "key-pressing",
+            /**
+             * @en The event type for the key up event
+             * @zh 当松开按键时触发的事件
+             */
+            KEY_UP = "keyup",
+            /**
+             * @en
+             * The event type for the devicemotion event
+             *
+             * @zh
+             * 重力感应
+             */
+            DEVICEMOTION = "devicemotion",
+            /**
+             * @en The event type for gamepad input
+             * @zh 手柄输入事件
+             */
+            GAMEPAD_INPUT = "gamepad-input",
+            /**
+             * @en The event type for gamepad device change, including gamepad connecting and disconnecting
+             * @zh 手柄设备改变时触发的事件,包括手柄连接,手柄断开连接
+             */
+            GAMEPAD_CHANGE = "gamepad-change",
+            /**
+             * @en The event type for 6DOF handle input
+             * @zh 6DOF手柄输入事件
+             */
+            HANDLE_INPUT = "handle-input",
+            /**
+             * @en The event type for handle pose input
+             * @zh 手柄姿态输入事件
+             */
+            HANDLE_POSE_INPUT = "handle-pose-input",
+            /**
+             * @en The event type for hmd pose input
+             * @zh 头戴显示器姿态输入事件
+             */
+            HMD_POSE_INPUT = "hmd-pose-input",
+            /**
+             * @en The event type for handheld pose input
+             * @zh 手持设备相机姿态输入事件
+             */
+            HANDHELD_POSE_INPUT = "handheld-pose-input"
+        }
+        export type _cocos_input_types_event_enum__SystemEventTypeUnion = SystemEventType | NodeEventType | _cocos_input_types_event_enum__InputEventType | string;
+        /**
+         * @en The event processor for Node
+         * @zh 节点事件类。
+         */
+        export class _cocos_scene_graph_node_event_processor__NodeEventProcessor {
+            /**
+             * @internal
+             */
+            static _maskComp: _types_globals__Constructor<Component> | null;
+            /**
+             * @internal
+             */
+            static callbacksInvoker: _cocos_core_event_callbacks_invoker__CallbacksInvoker<_cocos_scene_graph_node_event_processor__DispatcherEventType>;
+            /**
+             * Whether the node event is enabled
+             */
+            get isEnabled(): boolean;
+            /**
+             * The list of claimed touch ids
+             */
+            claimedTouchIdList: number[];
+            /**
+             * The masks in the parent chain of the node
+             */
+            maskList: _cocos_scene_graph_node_event_processor__IMask[] | null;
+            /**
+             * To cache camera priority.
+             */
+            cachedCameraPriority: number;
+            /**
+             * To record whether the mouse move in at the previous mouse event.
+             */
+            previousMouseIn: boolean;
+            /**
+             * The owner of node event processor.
+             */
+            get node(): Node;
+            /**
+             * Target in bubbling phase.
+             */
+            bubblingTarget: _cocos_core_event_callbacks_invoker__CallbacksInvoker<_cocos_input_types_event_enum__SystemEventTypeUnion> | null;
+            /**
+             * Target in capturing phase.
+             */
+            capturingTarget: _cocos_core_event_callbacks_invoker__CallbacksInvoker<_cocos_input_types_event_enum__SystemEventTypeUnion> | null;
+            /**
+             * Whether the node has registered the mouse event callback
+             */
+            shouldHandleEventMouse: boolean;
+            /**
+             * Whether the node has registered the touch event callback
+             */
+            shouldHandleEventTouch: boolean;
+            constructor(node: Node);
+            /**
+             * Set enable state of the node event processor
+             * @param value Enable state
+             * @param recursive Recursively set the state or not
+             * @returns void
+             */
+            setEnabled(value: boolean, recursive?: boolean): void;
+            reattach(): void;
+            destroy(): void;
+            on(type: NodeEventType, callback: _types_globals__AnyFunction, target?: unknown, useCapture?: boolean): _types_globals__AnyFunction;
+            once(type: NodeEventType, callback: _types_globals__AnyFunction, target?: unknown, useCapture?: boolean): _types_globals__AnyFunction;
+            off(type: NodeEventType, callback?: _types_globals__AnyFunction, target?: unknown, useCapture?: boolean): void;
+            targetOff(target: unknown): void;
+            emit(type: _cocos_input_types_event_enum__SystemEventTypeUnion, arg0?: any, arg1?: any, arg2?: any, arg3?: any, arg4?: any): void;
+            dispatchEvent(event: Event): void;
+            hasEventListener(type: _cocos_input_types_event_enum__SystemEventTypeUnion, callback?: _types_globals__AnyFunction, target?: unknown): boolean;
+            /**
+             * @zh
+             * 获得所提供的事件类型在目标捕获阶段监听的所有目标。
+             * 捕获阶段包括从根节点到目标节点的过程。
+             * 结果保存在数组参数中,并且必须从子节点排序到父节点。
+             *
+             * @param type - 一个监听事件类型的字符串。
+             * @param array - 接收目标的数组。
+             */
+            getCapturingTargets(type: string, targets: Node[]): void;
+            /**
+             * @zh
+             * 获得所提供的事件类型在目标冒泡阶段监听的所有目标。
+             * 冒泡阶段目标节点到根节点的过程。
+             * 结果保存在数组参数中,并且必须从子节点排序到父节点。
+             *
+             * @param type - 一个监听事件类型的字符串。
+             * @param array - 接收目标的数组。
+             */
+            getBubblingTargets(type: string, targets: Node[]): void;
+            onUpdatingSiblingIndex(): void;
+        }
         export type _types_globals__AbstractedConstructor<T = unknown> = new (...args: any[]) => T;
         /**
          * @en Node's UI properties abstraction
          * @zh 节点上 UI 相关的属性抽象类
@@ -62708,131 +63047,8 @@
             unuse(): void;
             reuse(args: any): void;
         }
         export type _extensions_ccpool_node_pool__Constructor<T = {}> = new (...args: any[]) => T;
-        /**
-         * @en The input event type
-         * @zh 输入事件类型
-         */
-        export enum _cocos_input_types_event_enum__InputEventType {
-            /**
-             * @en
-             * The event type for touch start event
-             *
-             * @zh
-             * 手指开始触摸事件。
-             */
-            TOUCH_START = "touch-start",
-            /**
-             * @en
-             * The event type for touch move event
-             *
-             * @zh
-             * 当手指在屏幕上移动时。
-             */
-            TOUCH_MOVE = "touch-move",
-            /**
-             * @en
-             * The event type for touch end event
-             *
-             * @zh
-             * 手指结束触摸事件。
-             */
-            TOUCH_END = "touch-end",
-            /**
-             * @en
-             * The event type for touch end event
-             *
-             * @zh
-             * 当手指在目标节点区域外离开屏幕时。
-             */
-            TOUCH_CANCEL = "touch-cancel",
-            /**
-             * @en
-             * The event type for mouse down events
-             *
-             * @zh
-             * 当鼠标按下时触发一次。
-             */
-            MOUSE_DOWN = "mouse-down",
-            /**
-             * @en
-             * The event type for mouse move events
-             *
-             * @zh
-             * 当鼠标在目标节点在目标节点区域中移动时,不论是否按下。
-             */
-            MOUSE_MOVE = "mouse-move",
-            /**
-             * @en
-             * The event type for mouse up events
-             *
-             * @zh
-             * 当鼠标从按下状态松开时触发一次。
-             */
-            MOUSE_UP = "mouse-up",
-            /**
-             * @en
-             * The event type for mouse wheel events
-             *
-             * @zh 手指开始触摸事件
-             */
-            MOUSE_WHEEL = "mouse-wheel",
-            /**
-             * @en The event type for the key down event
-             * @zh 当按下按键时触发的事件
-             */
-            KEY_DOWN = "keydown",
-            /**
-             * @en The event type for the key pressing event, the event will be continuously dispatched in the key pressed state
-             * @zh 当按着按键时触发的事件, 该事件在按下状态会持续派发
-             */
-            KEY_PRESSING = "key-pressing",
-            /**
-             * @en The event type for the key up event
-             * @zh 当松开按键时触发的事件
-             */
-            KEY_UP = "keyup",
-            /**
-             * @en
-             * The event type for the devicemotion event
-             *
-             * @zh
-             * 重力感应
-             */
-            DEVICEMOTION = "devicemotion",
-            /**
-             * @en The event type for gamepad input
-             * @zh 手柄输入事件
-             */
-            GAMEPAD_INPUT = "gamepad-input",
-            /**
-             * @en The event type for gamepad device change, including gamepad connecting and disconnecting
-             * @zh 手柄设备改变时触发的事件,包括手柄连接,手柄断开连接
-             */
-            GAMEPAD_CHANGE = "gamepad-change",
-            /**
-             * @en The event type for 6DOF handle input
-             * @zh 6DOF手柄输入事件
-             */
-            HANDLE_INPUT = "handle-input",
-            /**
-             * @en The event type for handle pose input
-             * @zh 手柄姿态输入事件
-             */
-            HANDLE_POSE_INPUT = "handle-pose-input",
-            /**
-             * @en The event type for hmd pose input
-             * @zh 头戴显示器姿态输入事件
-             */
-            HMD_POSE_INPUT = "hmd-pose-input",
-            /**
-             * @en The event type for handheld pose input
-             * @zh 手持设备相机姿态输入事件
-             */
-            HANDHELD_POSE_INPUT = "handheld-pose-input"
-        }
-        export type _cocos_input_types_event_enum__SystemEventTypeUnion = SystemEventType | NodeEventType | _cocos_input_types_event_enum__InputEventType | string;
         export type _pal_input__InputSourceButton = import('pal/input/input-source').InputSourceButton;
         export type _pal_input__InputSourceDpad = import('pal/input/input-source').InputSourceDpad;
         export type _pal_input__InputSourceStick = import('pal/input/input-source').InputSourceStick;
         export type _pal_input__InputSourcePosition = import('pal/input/input-source').InputSourcePosition;
@@ -63764,14 +63980,23 @@
             startRow: number;
             constructor(particleSystem: any);
             reset(): void;
         }
+        export type _cocos_particle_renderer_particle_system_renderer_cpu__PVData = [
+            math.Vec3,
+            math.Vec3,
+            math.Vec3,
+            math.Vec3,
+            number,
+            math.Vec3 | null,
+            null
+        ];
         export class _cocos_particle_models_particle_batch_model__default extends renderer.scene.Model {
             constructor();
             setCapacity(capacity: number): void;
             setVertexAttributes(mesh: Mesh | null, attrs: gfx.Attribute[]): void;
             updateMaterial(mat: Material): void;
-            addParticleVertexData(index: number, pvdata: any[]): void;
+            addParticleVertexData(index: number, pvdata: _cocos_particle_renderer_particle_system_renderer_cpu__PVData): void;
             addGPUParticleVertexData(p: _cocos_particle_particle__Particle, num: number, time: number): void;
             updateGPUParticles(num: number, time: number, dt: number): number;
             constructAttributeIndex(): void;
             updateIA(count: number): void;
@@ -63852,17 +64077,17 @@
             update(space: number, trans: math.Mat4): void;
             animate(p: _cocos_particle_particle__Particle, dt?: number): void;
         }
         export abstract class _cocos_particle_renderer_particle_system_renderer_base__ParticleSystemRendererBase {
-            protected _particleSystem: any;
+            protected _particleSystem: ParticleSystem | null;
             protected _model: _cocos_particle_models_particle_batch_model__default | null;
             protected _renderInfo: _cocos_particle_renderer_particle_system_renderer_data__default | null;
             protected _vertAttrs: gfx.Attribute[];
             protected _useInstance: boolean;
             constructor(info: _cocos_particle_renderer_particle_system_renderer_data__default);
             getUseInstance(): boolean;
             getInfo(): _cocos_particle_renderer_particle_system_renderer_data__default;
-            onInit(ps: Component): void;
+            onInit(ps: ParticleSystem): void;
             onEnable(): void;
             onDisable(): void;
             onDestroy(): void;
             attachToScene(): void;

@@ -136,20 +137,24 @@ const _matInsInfo: IMaterialInstanceInfo = {
subModelIdx: 0,
};

// TODO: we should not use this type, should use a uniform array type instead.
// Tracking issue: https://github.com/cocos/cocos-engine/issues/15553
export type PVData = [Vec3, Vec3, Vec3, Vec3, number, Vec3 | null, null];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it mean?

Copy link
Contributor Author

@PPpro PPpro Jun 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this means that this is an array type, and its element type is uncertain

for example

let a: PVData;
a[0] // Vec3 type
a[4] // number type

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and its element type is uncertain

I think it is defined in the PVData. As PVData[0] should be Vec3, PVData[1] should be Vec3, and so on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, because it was type of any before, it is very wierd to implement like this

we should not introduce different element types in an array, this issue should be solved here #15553

@@ -1160,7 +1160,7 @@ export class Node extends CCObject implements ISchedulable, CustomSerializable {
* ```
*/
public off (type: string, callback?: AnyFunction, target?: unknown, useCapture: any = false): void {
this._eventProcessor.off(type, callback, target, useCapture);
this._eventProcessor.off(type as NodeEventType, callback, target, useCapture);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just change the type of type from string to NodeEventType ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a public interface, the node currently support registering any custom event name, not only NodeEventType

NodeEventType is actually string value but it's some engine internal enumerate event

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If so, then internally should also be string too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created a new issue to deprecate node.on(type: string)
#15557

@minggo minggo requested a review from SantyWang June 27, 2023 08:40
@minggo minggo merged commit 4c0f664 into cocos:v3.8.1 Jun 28, 2023
10 checks passed
@PPpro PPpro deleted the 381-aot-add-type branch June 28, 2023 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants