Use ?. where it represents the intended semantics (#11512)
This commit is contained in:
@@ -236,7 +236,7 @@ export function setup(parentPath, container, listKey, key) {
|
||||
export function setKey(key) {
|
||||
this.key = key;
|
||||
this.node = this.container[this.key];
|
||||
this.type = this.node && this.node.type;
|
||||
this.type = this.node?.type;
|
||||
}
|
||||
|
||||
export function requeue(pathToQueue = this) {
|
||||
|
||||
@@ -170,7 +170,7 @@ function hoistFunctionEnvironment(
|
||||
p.isClassProperty({ static: false })
|
||||
);
|
||||
});
|
||||
const inConstructor = thisEnvFn && thisEnvFn.node.kind === "constructor";
|
||||
const inConstructor = thisEnvFn?.node.kind === "constructor";
|
||||
|
||||
if (thisEnvFn.isClassProperty()) {
|
||||
throw fnPath.buildCodeFrameError(
|
||||
|
||||
@@ -160,7 +160,7 @@ function _evaluate(path, state) {
|
||||
return deopt(binding.path, state);
|
||||
}
|
||||
|
||||
if (binding && binding.hasValue) {
|
||||
if (binding?.hasValue) {
|
||||
return binding.value;
|
||||
} else {
|
||||
if (node.name === "undefined") {
|
||||
|
||||
@@ -53,7 +53,7 @@ export function _getTypeAnnotation(): ?Object {
|
||||
}
|
||||
|
||||
inferer = inferers[this.parentPath.type];
|
||||
if (inferer && inferer.validParent) {
|
||||
if (inferer?.validParent) {
|
||||
return this.parentPath.getTypeAnnotation();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ export function VariableDeclarator() {
|
||||
|
||||
let type = init.getTypeAnnotation();
|
||||
|
||||
if (type && type.type === "AnyTypeAnnotation") {
|
||||
if (type?.type === "AnyTypeAnnotation") {
|
||||
// Detect "var foo = Array()" calls so we can optimize for arrays vs iterables.
|
||||
if (
|
||||
init.isCallExpression() &&
|
||||
|
||||
@@ -7,7 +7,7 @@ export function remove() {
|
||||
this._assertUnremoved();
|
||||
|
||||
this.resync();
|
||||
if (!this.opts || !this.opts.noScope) {
|
||||
if (!this.opts?.noScope) {
|
||||
this._removeFromScope();
|
||||
}
|
||||
|
||||
|
||||
@@ -196,7 +196,7 @@ export function _replaceWith(node) {
|
||||
t.validate(this.parent, this.key, node);
|
||||
}
|
||||
|
||||
this.debug(`Replace with ${node && node.type}`);
|
||||
this.debug(`Replace with ${node?.type}`);
|
||||
|
||||
this.node = this.container[this.key] = node;
|
||||
}
|
||||
@@ -217,7 +217,7 @@ export function replaceExpressionWithStatements(nodes: Array<Object>) {
|
||||
}
|
||||
|
||||
const functionParent = this.getFunctionParent();
|
||||
const isParentAsync = functionParent && functionParent.is("async");
|
||||
const isParentAsync = functionParent?.is("async");
|
||||
|
||||
const container = t.arrowFunctionExpression([], t.blockStatement(nodes));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user