From faa6c9f7083a3f46cb7e82da9b339c0525e03317 Mon Sep 17 00:00:00 2001 From: Justin Ridgewell Date: Mon, 5 Jun 2017 13:56:28 -0400 Subject: [PATCH] Use nil --- packages/babel-plugin-transform-optional-chaining/src/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/babel-plugin-transform-optional-chaining/src/index.js b/packages/babel-plugin-transform-optional-chaining/src/index.js index 4272827238..f32eb713ec 100644 --- a/packages/babel-plugin-transform-optional-chaining/src/index.js +++ b/packages/babel-plugin-transform-optional-chaining/src/index.js @@ -4,6 +4,7 @@ export default function ({ types: t }) { function optional(path, key, replacementPath, needsContext = false, loose = false) { const { scope } = path; const optionals = [path.node]; + const nil = scope.buildUndefinedNode(); let objectPath = path.get(key); while (objectPath.isMemberExpression()) { @@ -65,7 +66,7 @@ export default function ({ types: t }) { replacementPath.replaceWith(t.conditionalExpression( t.binaryExpression("==", check, t.nullLiteral()), - scope.buildUndefinedNode(), + nil, replacementPath.node ));