Set type of variable to type of contained variable for grids and arrays