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

Fix compatibilty issues after PR #18282 #18345

Merged
merged 1 commit into from
Feb 18, 2025

Conversation

dumganhar
Copy link
Contributor

Re: #18282

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.

Copy link

Code Size Check Report

Wechat (WASM) Before After Diff
2D Empty (legacy pipeline) 1001794 bytes 1001794 bytes ✅ 0 bytes
2D All (legacy pipeline) 2408779 bytes 2408779 bytes ✅ 0 bytes
2D All (new pipeline) 2498268 bytes 2498268 bytes ✅ 0 bytes
(2D + 3D) All 5380494 bytes 5380494 bytes ✅ 0 bytes
Web (WASM + ASMJS) Before After Diff
(2D + 3D) All 16603945 bytes 16603945 bytes ✅ 0 bytes

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -24369,11 +24369,26 @@
          * @param className The class name of the target component
          * @example
          * ```
          * // get custom test class.
-         * var test = node.getComponent("Test");
+         * var test = node.getComponent("Test") as Test | null;
          * ```
          */
+        getComponent(className: string): Component | null;
+        /**
+         * @en
+         * Returns the component of supplied type if the node has one attached, null if it doesn't.
+         * You can also get component in the node by passing in the name of the script.
+         * @zh
+         * 获取节点上指定类型的组件,如果节点有附加指定类型的组件,则返回,如果没有则为空。
+         * 传入参数也可以是脚本的名称。
+         * @param className The class name of the target component
+         * @example
+         * ```
+         * // get custom test class.
+         * var test = node.getComponent<Test>("Test");
+         * ```
+         */
         getComponent<T extends Component>(className: string): T | null;
         /**
          * @en Returns all components of given type in the node.
          * @zh 返回节点上指定类型的所有组件。
@@ -24383,9 +24398,23 @@
         /**
          * @en Returns all components of given type in the node.
          * @zh 返回节点上指定类型的所有组件。
          * @param className The class name of the target component
+         * @example
+         * ```
+         * var test = node.getComponents('Test') as Test[];
+         * ```
          */
+        getComponents(className: string): Component[];
+        /**
+         * @en Returns all components of given type in the node.
+         * @zh 返回节点上指定类型的所有组件。
+         * @param className The class name of the target component
+         * @example
+         * ```
+         * var test = node.getComponents<Test>('Test');
+         * ```
+         */
         getComponents<T extends Component>(className: string): T[];
         /**
          * @en Returns the component of given type in any of its children using depth first search.
          * @zh 递归查找所有子节点中第一个匹配指定类型的组件。
@@ -24401,11 +24430,21 @@
          * @zh 递归查找所有子节点中第一个匹配指定类型的组件。
          * @param className The class name of the target component
          * @example
          * ```
-         * var Test = node.getComponentInChildren("Test");
+         * var test = node.getComponentInChildren("Test") as Test | null;
          * ```
          */
+        getComponentInChildren(className: string): Component | null;
+        /**
+         * @en Returns the component of given type in any of its children using depth first search.
+         * @zh 递归查找所有子节点中第一个匹配指定类型的组件。
+         * @param className The class name of the target component
+         * @example
+         * ```
+         * var test = node.getComponentInChildren<Test>("Test");
+         * ```
+         */
         getComponentInChildren<T extends Component>(className: string): T | null;
         /**
          * @en Returns all components of given type in self or any of its children.
          * @zh 递归查找自身或所有子节点中指定类型的组件
@@ -24421,11 +24460,21 @@
          * @zh 递归查找自身或所有子节点中指定类型的组件
          * @param className The class name of the target component
          * @example
          * ```
-         * var tests = node.getComponentsInChildren("Test");
+         * var tests = node.getComponentsInChildren("Test") as Test[];
          * ```
          */
+        getComponentsInChildren(className: string): Component[];
+        /**
+         * @en Returns all components of given type in self or any of its children.
+         * @zh 递归查找自身或所有子节点中指定类型的组件
+         * @param className The class name of the target component
+         * @example
+         * ```
+         * var tests = node.getComponentsInChildren<Test>("Test");
+         * ```
+         */
         getComponentsInChildren<T extends Component>(className: string): T[];
         /**
          * @en Adds a component class to the node. You can also add component to node by passing in the name of the script.
          * @zh 向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。
@@ -24443,11 +24492,22 @@
          * @param className The class name of the component to add
          * @throws `TypeError` if the `className` does not specify a cc-class constructor extending the `Component`.
          * @example
          * ```
-         * var test = node.addComponent("Test");
+         * var test = node.addComponent("Test") as Test;
          * ```
          */
+        addComponent(className: string): Component;
+        /**
+         * @en Adds a component class to the node. You can also add component to node by passing in the name of the script.
+         * @zh 向节点添加一个指定类型的组件类,你还可以通过传入脚本的名称来添加组件。
+         * @param className The class name of the component to add
+         * @throws `TypeError` if the `className` does not specify a cc-class constructor extending the `Component`.
+         * @example
+         * ```
+         * var test = node.addComponent<Test>("Test");
+         * ```
+         */
         addComponent<T extends Component>(className: string): T;
         /**
          * @en
          * Removes a component identified by the given name or removes the component object given.

@minggo minggo merged commit a67a0dc into cocos:v3.8.6 Feb 18, 2025
13 checks passed
bofeng-song pushed a commit to bofeng-song/engine that referenced this pull request Feb 18, 2025
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