Skip to content

Commit

Permalink
补充泛型参数
Browse files Browse the repository at this point in the history
  • Loading branch information
esengine committed Aug 20, 2021
1 parent d54ccaf commit 5d16091
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion source/bin/framework.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions source/src/ECS/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]) {
Expand Down

0 comments on commit 5d16091

Please sign in to comment.