Skip to content

Commit 0140173

Browse files
AgentEnderclaude
andcommitted
fix(cli-forge): improve peerDependenciesMeta type checking
- Use safer property access pattern for peerDependenciesMeta - Check for 'dev' property existence before accessing - Improves TypeScript type narrowing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 52a29de commit 0140173

File tree

1 file changed

+7
-7
lines changed
  • packages/cli-forge/bin/commands

1 file changed

+7
-7
lines changed

packages/cli-forge/bin/commands/init.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ const CLI_FORGE_VERSION = CLI_FORGE_PACKAGE_JSON.version;
1919
const DEV_PEER_DEPS = Object.entries(
2020
CLI_FORGE_PACKAGE_JSON.peerDependencies
2121
).reduce((acc, [dep, version]) => {
22-
if (
23-
// The dev prop doesn't actually do anything for npm/pnpm/yarn,
24-
// but we are using it to mark when a peer dep is only used at dev time.
25-
// In these cases, we can safely add them to the devDependencies of the
26-
// generated CLI.
22+
// The dev prop doesn't actually do anything for npm/pnpm/yarn,
23+
// but we are using it to mark when a peer dep is only used at dev time.
24+
// In these cases, we can safely add them to the devDependencies of the
25+
// generated CLI.
26+
const meta =
2727
CLI_FORGE_PACKAGE_JSON.peerDependenciesMeta[
2828
dep as keyof typeof CLI_FORGE_PACKAGE_JSON.peerDependenciesMeta
29-
]?.dev
30-
) {
29+
];
30+
if (meta && 'dev' in meta && meta.dev) {
3131
acc[dep] = version;
3232
}
3333
return acc;

0 commit comments

Comments
 (0)