How can I achieve getComponent<T>()?

Is it possible make a generic getComponent() function?

I’m trying to create a generic class and has T extends Component.
But I can’t get the component by calling something like getComponent()

Is there any workaround?

Hello there!

Try checking this out:
https://docs.cocos.com/creator/manual/en/scripting/access-node-component.html

I hope it helps!

You can try modifying the getComponent function in cc.d.ts.