Use ?. where it represents the intended semantics (#11512)
This commit is contained in:
@@ -71,8 +71,9 @@ export function* findRelativeConfig(
|
||||
loc,
|
||||
envName,
|
||||
caller,
|
||||
packageData.pkg && packageData.pkg.dirname === loc
|
||||
? packageToBabelConfig(packageData.pkg)
|
||||
packageData.pkg?.dirname === loc
|
||||
? // $FlowIgnore - packageData.pkg is not null
|
||||
packageToBabelConfig((packageData.pkg: ConfigFile))
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ export type { PartialConfig } from "./partial";
|
||||
|
||||
const loadOptionsRunner = gensync<[mixed], Object | null>(function*(opts) {
|
||||
const config = yield* loadFullConfig(opts);
|
||||
return config ? config.options : null;
|
||||
// NOTE: We want to return "null" explicitly, while ?. alone returns undefined
|
||||
return config?.options ?? null;
|
||||
});
|
||||
|
||||
const maybeErrback = runner => (opts: mixed, callback: Function) => {
|
||||
|
||||
@@ -25,15 +25,7 @@ type TransformFile = {
|
||||
|
||||
const transformFileRunner = gensync<[string, ?InputOptions], FileResult | null>(
|
||||
function*(filename, opts) {
|
||||
let options;
|
||||
if (opts == null) {
|
||||
options = { filename };
|
||||
} else if (opts && typeof opts === "object") {
|
||||
options = {
|
||||
...opts,
|
||||
filename,
|
||||
};
|
||||
}
|
||||
const options = { ...opts, filename };
|
||||
|
||||
const config: ResolvedConfig | null = yield* loadConfig(options);
|
||||
if (config === null) return null;
|
||||
|
||||
@@ -44,7 +44,7 @@ const blockHoistPlugin = {
|
||||
let hasChange = false;
|
||||
for (let i = 0; i < node.body.length; i++) {
|
||||
const bodyNode = node.body[i];
|
||||
if (bodyNode && bodyNode._blockHoist != null) {
|
||||
if (bodyNode?._blockHoist != null) {
|
||||
hasChange = true;
|
||||
break;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ const blockHoistPlugin = {
|
||||
if (!hasChange) return;
|
||||
|
||||
node.body = sortBy(node.body, function(bodyNode) {
|
||||
let priority = bodyNode && bodyNode._blockHoist;
|
||||
let priority = bodyNode?._blockHoist;
|
||||
if (priority == null) priority = 1;
|
||||
if (priority === true) priority = 2;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user