Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: improved type safety of platformConfig in createRun function #2286

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import {supportedPlatforms} from '../../config/supportedPlatforms';
const createBuild =
({platformName}: BuilderCommand) =>
async (_: Array<string>, ctx: Config, args: BuildFlags) => {
const platformConfig = ctx.project[platformName] as IOSProjectConfig;
const platformConfig = ctx.project[platformName] as
| IOSProjectConfig
| undefined;
hoonjoo-park marked this conversation as resolved.
Show resolved Hide resolved

if (
platformConfig === undefined ||
supportedPlatforms[platformName] === undefined
Expand All @@ -21,9 +24,9 @@ const createBuild =
}

let installedPods = false;
if (platformConfig?.automaticPodsInstallation || args.forcePods) {
const isAppRunningNewArchitecture = platformConfig?.sourceDir
? await getArchitecture(platformConfig?.sourceDir)
if (platformConfig.automaticPodsInstallation || args.forcePods) {
const isAppRunningNewArchitecture = platformConfig.sourceDir
? await getArchitecture(platformConfig.sourceDir)
: undefined;

await resolvePods(ctx.root, ctx.dependencies, platformName, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ const createRun =
async (_: Array<string>, ctx: Config, args: FlagsT) => {
// React Native docs assume platform is always ios/android
link.setPlatform('ios');
const platformConfig = ctx.project[platformName] as IOSProjectConfig;
const platformConfig = ctx.project[platformName] as
| IOSProjectConfig
| undefined;
szymonrybczak marked this conversation as resolved.
Show resolved Hide resolved
const {sdkNames, readableName: platformReadableName} =
getPlatformInfo(platformName);

Expand All @@ -67,9 +69,9 @@ const createRun =
let {packager, port} = args;
let installedPods = false;
// check if pods need to be installed
if (platformConfig?.automaticPodsInstallation || args.forcePods) {
const isAppRunningNewArchitecture = platformConfig?.sourceDir
? await getArchitecture(platformConfig?.sourceDir)
if (platformConfig.automaticPodsInstallation || args.forcePods) {
const isAppRunningNewArchitecture = platformConfig.sourceDir
? await getArchitecture(platformConfig.sourceDir)
: undefined;

await resolvePods(ctx.root, ctx.dependencies, platformName, {
Expand Down
Loading