Alex Lewis bb6cc61979 fix(optional chaining): Optional delete returns true with nullish base (#10806)
Per issue 10805, the return value when using delete on a nullish base is
currently undefined. The correct return type should be true.
2019-12-04 12:56:25 +01:00

23 lines
354 B
JavaScript

"use strict";
const obj = {
a: {
b: 0,
},
};
let test = delete obj?.a?.b;
expect(obj.a.b).toBeUndefined();
expect(test).toBe(true);
test = delete obj?.a.b;
expect(obj.a.b).toBeUndefined();
expect(test).toBe(true);
test = delete obj?.b?.b;
expect(obj.b).toBeUndefined();
expect(test).toBe(true);
delete obj?.a;
expect(obj.a).toBeUndefined();