Accessing List in another gameObject via script

I’m trying to iterate through all stored gameObject in a List and if a certain condition is met (in this case, if the gameObject is seen by the player), access another list in the current gameObject and add to it:

var List1 : new List.<GameObject>(); //contains all Characters in scene

var SeenBy : new List.<GameObject>();
    
for (var CurrentObject : GameObject in List1)  
{ 
    CurrentObject.GetComponent(LineOfSight).SeenBy.Add(gameObject); //access the other objects SeenBy List and add this gameObject to it
}

However, I get this error:

Assets/Scripts/LineOfSight.js(7,46): BCE0023: No appropriate version of ‘UnityEngine.GameObject.GetComponent’ for the argument list ‘(function(UnityEngine.GameObject): boolean)’ was found.

What am I doing wrong? How do I access Lists or even normal variables (tried that too via GetComponent) while iterating through a List?

Might it be that you have an additional method called “LineOfSight” which returns a boolean?

If yes, you could either rename that method or use

GetComponent.<LineOfSight>()

to be more specific that you want the type, not let Unity figure out what LineOfSight is (like I said, the error message says that there is also a method with exactly this name).