Can't add GameObjects to ArrayList

I am sending information from my item to my inventory. Telling the inventory to add the item. Gives me a null reference exception.

Item.js :

inventory.AddItem(this as GameObject);    

Inventory.js :

var items : ArrayList;

function AddItem (item : GameObject) {
         
   items.Add(item.gameObject);  //Error happens here
     
}

this is not a GameObject; its class is derived from MonoBehaviour. You use the correct semantics later on:

.gameObject

Using the shorthand for this.gameObject works fine:

inventory.AddItem(gameObject);

However, you should use something other than an ArrayList; a List is probably what you want. Using .gameObject on item is useless; I don’t even know why that compiles.

import System.Collections.Generic;

var items : List.<GameObject>;

function AddItem(item:GameObject) {
   items.Add(item);
}