Generic function does not work...

Hi I’m trying to implement an easy generic function

I want to find out if a component (like a script, collider, etc.) is attached to an transform node.

Actually GetComponent should return null if that Kind of Type is not attached.
What am I doing wrong?

Here some code snippets:

public static bool rootParentHasComponent(Transform node) {
//…
if(node.GetComponent()!=null) return true;
//…
}

T isn’t declared here. Try this one :

public static bool rootParentHasComponent<T>(Transform node) {
    //...
    if(node.GetComponent<T>()!=null) return true;
    //...
}

But that will generate an error, because T need to be a Component, so :

public static bool rootParentHasComponent<T>(Transform node) where T : Component
{
    //...
    if (node.GetComponent<T>() != null) return true;
    //...
}