* Implement transform for nullish-coalescing operator * Update example output * Switch from BinaryExpression to LogicalExpression * Address review comments - Use generateUidIdentifierBasedOnNode - Inline "??" - Clone ref node - Move "??" to LogicalExpression in babel-types * Fix reference to @babel/helper-plugin-test-runner * Fix reference to @babel/plugin-syntax-nullish-coalescing-operator * Don't use parent scope * Remove .vscode from .gitignore, change 'lib/index.js' to 'lib' * Ensure `document.all ?? 0 === document.all` * Fix note and copy to an inline comment
20 lines
497 B
JavaScript
20 lines
497 B
JavaScript
assert.equal(null ?? undefined, undefined);
|
|
assert.equal(undefined ?? null, null);
|
|
assert.equal(false ?? true, false);
|
|
assert.equal(0 ?? 1, 0);
|
|
assert.equal("" ?? "foo", "");
|
|
|
|
var obj = { exists: true };
|
|
assert.equal(obj.exists ?? false, true);
|
|
assert.equal(obj.doesNotExist ?? "foo", "foo");
|
|
|
|
var counter = 0;
|
|
function sideEffect() { return counter++; }
|
|
assert.equal(sideEffect() ?? -1, 0);
|
|
|
|
var counter2 = 0;
|
|
var obj2 = {
|
|
get foo() { return counter2++; }
|
|
};
|
|
assert.equal(obj2.foo ?? -1, 0);
|