Typescript Array Index Of Bound Exception