-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 tasks
9romise
approved these changes
Feb 18, 2025
Code Size Check Report
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
approved these changes
Feb 18, 2025
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Re: #18282
Changelog
Continuous Integration
This pull request:
Compatibility Check
This pull request: