Fix typeof incorrectly returning null for arrays and dictionaries

fixes #8002