Skip to content

Commit 397b02c

Browse files
committed
Fix defaulting type errors
1 parent 37624e0 commit 397b02c

File tree

2 files changed

+19
-8
lines changed
  • packages/react-native/scripts/codegen/generate-artifacts-executor

2 files changed

+19
-8
lines changed

packages/react-native/scripts/codegen/generate-artifacts-executor/index.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,29 +210,38 @@ function readOutputDirFromPkgJson(
210210

211211
function computeOutputPath(
212212
projectRoot /*: string */,
213-
baseOutputPath /*: string | void | null */,
213+
optionalBaseOutputPath /*: string | void | null */,
214214
pkgJson /*: $FlowFixMe */,
215215
platform /*: string */,
216-
) {
217-
if (baseOutputPath == null) {
216+
) /*: string */ {
217+
let baseOutputPath /*: string */;
218+
if (optionalBaseOutputPath == null) {
218219
const outputDirFromPkgJson = readOutputDirFromPkgJson(pkgJson, platform);
219220
if (outputDirFromPkgJson != null) {
220-
// $FlowFixMe[reassign-const]
221221
baseOutputPath = path.join(projectRoot, outputDirFromPkgJson);
222222
} else {
223-
// $FlowFixMe[reassign-const]
224223
baseOutputPath = projectRoot;
225224
}
225+
} else {
226+
baseOutputPath = optionalBaseOutputPath;
226227
}
227228
if (pkgJsonIncludesGeneratedCode(pkgJson)) {
228229
// Don't create nested directories for libraries to make importing generated headers easier.
229230
return baseOutputPath;
230231
}
231232
if (platform === 'android') {
232-
return defaultOutputPathForAndroid(baseOutputPath);
233+
return defaultOutputPathForAndroid(
234+
baseOutputPath != null && baseOutputPath.length > 0
235+
? baseOutputPath
236+
: projectRoot,
237+
);
233238
}
234239
if (platform === 'ios') {
235-
return defaultOutputPathForIOS(baseOutputPath);
240+
return defaultOutputPathForIOS(
241+
baseOutputPath != null && baseOutputPath.length > 0
242+
? baseOutputPath
243+
: projectRoot,
244+
);
236245
}
237246
return baseOutputPath;
238247
}

packages/react-native/scripts/codegen/generate-artifacts-executor/utils.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ function readGeneratedAutolinkingOutput(
104104
// NOTE: Generated by scripts/cocoapods/autolinking.rb in list_native_modules (called by use_native_modules)
105105
// The `baseOutputPath` is based on a CLI argument and optional
106106
const autolinkingGeneratedPath = path.resolve(
107-
baseOutputPath || projectRoot,
107+
baseOutputPath != null && baseOutputPath.length > 0
108+
? baseOutputPath
109+
: projectRoot,
108110
'build/generated/autolinking/autolinking.json',
109111
);
110112
if (fs.existsSync(autolinkingGeneratedPath)) {

0 commit comments

Comments
 (0)