robust type checking for js