handle a bunch of (but not all) corner cases around type coercion, attempting to compensate for type literal differences between Python and javascript.