Skip to content

Commit

Permalink
fix: handle loadConfig signature change (#2125)
Browse files Browse the repository at this point in the history
  • Loading branch information
tido64 committed Jul 16, 2024
1 parent cf8cb54 commit 1b24387
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 7 additions & 1 deletion android/autolink.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,13 @@ function loadConfig(json, projectRoot) {
["react-native", "@react-native-community/cli"],
projectRoot
);
const config = loadConfig(projectRoot);

// The signature of `loadConfig` changed in 14.0.0:
// https://github.com/react-native-community/cli/commit/b787c89edb781bb788576cd615d2974fc81402fc
const argc = loadConfig.length;
// @ts-expect-error TS2345: Argument of type X is not assignable to parameter of type Y
const config = loadConfig(argc === 1 ? { projectRoot } : projectRoot);

const prunedConfig = pruneDependencies(config);
ensureDirForFile(json);
writeTextFile(json, JSON.stringify(prunedConfig, undefined, 2) + "\n");
Expand Down
5 changes: 4 additions & 1 deletion windows/project.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ export const loadReactNativeConfig = memo((rnWindowsPath) => {
["@react-native-community/cli"],
rnWindowsPath
);
return loadConfig();
// The signature of `loadConfig` changed in 14.0.0:
// https://github.com/react-native-community/cli/commit/b787c89edb781bb788576cd615d2974fc81402fc
// @ts-expect-error TS2345: Argument of type X is not assignable to parameter of type Y
return loadConfig.length === 1 ? loadConfig({}) : loadConfig();
});

/**
Expand Down

0 comments on commit 1b24387

Please sign in to comment.