Skip to content

Commit e827759

Browse files
jdaltonclaude
andcommitted
refactor: improve type specificity with imported types
Replace generic Record<string, any> with specific types: - cmd.mts: Use MeowFlags type for flagsToFilter parameter - update-manifest-by-agent.mts: Use Overrides type for value parameter, replace Array<[string | symbol, any]> with unknown, and improve oldOverrides extraction with proper type narrowing These changes leverage existing type definitions for better type safety and IDE autocomplete support. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 6418410 commit e827759

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/commands/optimize/update-manifest-by-agent.mts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const depFields = [
3535
]
3636

3737
function getEntryIndexes(
38-
entries: Array<[string | symbol, any]>,
38+
entries: Array<[string | symbol, unknown]>,
3939
keys: Array<string | symbol>,
4040
): number[] {
4141
return keys
@@ -45,14 +45,14 @@ function getEntryIndexes(
4545
}
4646

4747
function getLowestEntryIndex(
48-
entries: Array<[string | symbol, any]>,
48+
entries: Array<[string | symbol, unknown]>,
4949
keys: Array<string | symbol>,
5050
) {
5151
return getEntryIndexes(entries, keys)?.[0] ?? -1
5252
}
5353

5454
function getHighestEntryIndex(
55-
entries: Array<[string | symbol, any]>,
55+
entries: Array<[string | symbol, unknown]>,
5656
keys: Array<string | symbol>,
5757
) {
5858
return getEntryIndexes(entries, keys).at(-1) ?? -1
@@ -61,19 +61,23 @@ function getHighestEntryIndex(
6161
function updatePkgJsonField(
6262
editablePkgJson: EditablePackageJson,
6363
field: string,
64-
value: any,
64+
value: Overrides,
6565
) {
6666
const oldValue = editablePkgJson.content[field]
6767
if (oldValue) {
6868
// The field already exists so we simply update the field value.
6969
if (field === PNPM) {
7070
const isPnpmObj = isObject(oldValue)
7171
if (hasKeys(value)) {
72+
const oldOverrides =
73+
isPnpmObj && isObject((oldValue as Record<string, unknown>)[OVERRIDES])
74+
? ((oldValue as Record<string, unknown>)[OVERRIDES] as Overrides)
75+
: {}
7276
editablePkgJson.update({
7377
[field]: {
7478
...(isPnpmObj ? oldValue : {}),
7579
overrides: {
76-
...(isPnpmObj ? (oldValue as any)[OVERRIDES] : {}),
80+
...oldOverrides,
7781
...value,
7882
},
7983
},

src/utils/cmd.mts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { spawn } from '@socketsecurity/registry/lib/spawn'
2727
import constants, { FLAG_CONFIG, FLAG_HELP } from '../constants.mts'
2828
import { camelToKebab } from './strings.mts'
2929

30+
import type { MeowFlags } from '../flags.mts'
3031
import type { CResult } from '../types.mts'
3132

3233
const { WIN32 } = constants
@@ -41,7 +42,7 @@ const helpFlags = new Set([FLAG_HELP, '-h'])
4142
/**
4243
* Convert flag values to array format for processing.
4344
*/
44-
export function cmdFlagValueToArray(value: any): string[] {
45+
export function cmdFlagValueToArray(value: unknown): string[] {
4546
if (typeof value === 'string') {
4647
return value.trim().split(/, */).filter(Boolean)
4748
}
@@ -88,7 +89,7 @@ export function cmdPrefixMessage(cmdName: string, text: string): string {
8889
*/
8990
export function filterFlags(
9091
argv: readonly string[],
91-
flagsToFilter: Record<string, any>,
92+
flagsToFilter: MeowFlags,
9293
exceptions?: string[] | undefined,
9394
): string[] {
9495
const filtered: string[] = []

0 commit comments

Comments
 (0)