补充泛型参数

This commit is contained in:
yhh
2021-08-20 19:10:20 +08:00
parent d54ccaf629
commit 5d1609111c
2 changed files with 5 additions and 5 deletions

View File

@@ -206,7 +206,7 @@ declare module es {
setEnabled(isEnabled: boolean): this;
setUpdateOrder(updateOrder: number): this;
addComponent<T extends Component>(component: T): T;
getComponent(type: new (...args: any[]) => Component): Component;
getComponent<T extends Component>(type: new (...args: any[]) => T): T;
getComponents(typeName: any, componentList?: any[]): any[];
hasComponent(type: new (...args: any[]) => Component): boolean;
removeComponent(component?: Component): void;

View File

@@ -119,12 +119,12 @@ module es {
return this;
}
public addComponent<T extends Component>(component: T) {
return this.entity.addComponent(component);
public addComponent<T extends Component>(component: T): T {
return this.entity.addComponent<T>(component);
}
public getComponent(type: new (...args: any[])=>Component) {
return this.entity.getComponent(type);
public getComponent<T extends Component>(type: new (...args: any[])=>T): T {
return this.entity.getComponent<T>(type);
}
public getComponents(typeName: any, componentList?: any[]) {