Skip to content

Commit f4e3198

Browse files
conorluddyclaude
andcommitted
fix: resolve TypeScript compilation errors in CI
- Fix type incompatibility between CachedSimulatorList interfaces - Change lastUsed from string to Date type to match simulator-cache - Simplify metadata objects to use only primitive types - Add availability property to SimulatorFilters interface - Fix metadata type constraints in response cache - Remove unused imports and interfaces - Replace non-null assertions with safe alternatives - Fix all ESLint errors and warnings - Update tests to use Date type for lastUsed property 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7636095 commit f4e3198

File tree

4 files changed

+38
-40
lines changed

4 files changed

+38
-40
lines changed

src/tools/simctl/list.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { executeCommand, buildSimctlCommand } from '../../utils/command.js';
2-
import type { ToolResult, SimulatorList, OutputFormat } from '../../types/xcode.js';
1+
import type { OutputFormat } from '../../types/xcode.js';
32
import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
43
import { simulatorCache, type CachedSimulatorList } from '../../state/simulator-cache.js';
54
import {
@@ -8,28 +7,28 @@ import {
87
createProgressiveSimulatorResponse,
98
} from '../../utils/response-cache.js';
109

11-
interface SimctlListToolArgs {
10+
interface SimctlListArgs {
1211
deviceType?: string;
1312
runtime?: string;
1413
availability?: 'available' | 'unavailable' | 'all';
1514
outputFormat?: OutputFormat;
1615
concise?: boolean;
1716
}
1817

19-
export async function simctlListTool(args: any) {
18+
export async function simctlListTool(args: SimctlListArgs) {
2019
const {
2120
deviceType,
2221
runtime,
2322
availability = 'available',
2423
outputFormat = 'json',
2524
concise = true,
26-
} = args as SimctlListToolArgs;
25+
} = args;
2726

2827
try {
2928
// Use the new caching system
3029
const cachedList = await simulatorCache.getSimulatorList();
3130

32-
let responseData: any;
31+
let responseData: Record<string, unknown> | string;
3332

3433
// Use progressive disclosure by default (concise=true)
3534
if (concise && outputFormat === 'json') {
@@ -46,8 +45,7 @@ export async function simctlListTool(args: any) {
4645
metadata: {
4746
totalDevices: summary.totalDevices,
4847
availableDevices: summary.availableDevices,
49-
filters: { deviceType, runtime, availability },
50-
summary,
48+
hasFilters: !!(deviceType || runtime || availability !== 'available'),
5149
},
5250
});
5351

@@ -117,16 +115,16 @@ function filterCachedSimulatorList(
117115
// Filter device types if specified
118116
if (filters.deviceType) {
119117
filtered.devicetypes = list.devicetypes.filter(dt =>
120-
dt.name.toLowerCase().includes(filters.deviceType!.toLowerCase())
118+
dt.name.toLowerCase().includes(filters.deviceType.toLowerCase())
121119
);
122120
}
123121

124122
// Filter runtimes if specified
125123
if (filters.runtime) {
126124
filtered.runtimes = list.runtimes.filter(
127125
rt =>
128-
rt.name.toLowerCase().includes(filters.runtime!.toLowerCase()) ||
129-
rt.version.includes(filters.runtime!)
126+
rt.name.toLowerCase().includes(filters.runtime.toLowerCase()) ||
127+
rt.version.includes(filters.runtime)
130128
);
131129
}
132130

src/tools/xcodebuild/build.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,8 @@ interface BuildToolArgs {
1414
derivedDataPath?: string;
1515
}
1616

17-
export async function xcodebuildBuildTool(args: any) {
18-
const {
19-
projectPath,
20-
scheme,
21-
configuration = 'Debug',
22-
destination,
23-
sdk,
24-
derivedDataPath,
25-
} = args as BuildToolArgs;
17+
export async function xcodebuildBuildTool(args: BuildToolArgs) {
18+
const { projectPath, scheme, configuration = 'Debug', destination, sdk, derivedDataPath } = args;
2619

2720
try {
2821
// Validate inputs
@@ -90,11 +83,11 @@ export async function xcodebuildBuildTool(args: any) {
9083
destination: finalConfig.destination,
9184
sdk: finalConfig.sdk,
9285
duration,
93-
summary,
94-
smartDefaultsUsed: {
95-
destination: !destination && smartDestination !== destination,
96-
configuration: !args.configuration && finalConfig.configuration !== 'Debug',
97-
},
86+
success: summary.success,
87+
errorCount: summary.errorCount,
88+
warningCount: summary.warningCount,
89+
smartDestinationUsed: !destination && smartDestination !== destination,
90+
smartConfigurationUsed: !args.configuration && finalConfig.configuration !== 'Debug',
9891
},
9992
});
10093

@@ -144,7 +137,9 @@ export async function xcodebuildBuildTool(args: any) {
144137
}
145138
}
146139

147-
async function getSmartDestination(preferredConfig: any): Promise<string | undefined> {
140+
async function getSmartDestination(
141+
preferredConfig: BuildConfig | null
142+
): Promise<string | undefined> {
148143
// If preferred config has a destination, use it
149144
if (preferredConfig?.destination) {
150145
return preferredConfig.destination;

src/utils/response-cache.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,16 @@ export function extractTestSummary(output: string, stderr: string, exitCode: num
163163
};
164164
}
165165

166+
interface SimulatorDeviceForSummary {
167+
isAvailable: boolean;
168+
state: string;
169+
name: string;
170+
udid: string;
171+
lastUsed?: Date;
172+
}
173+
166174
interface CachedSimulatorList {
167-
devices: Record<
168-
string,
169-
Array<{
170-
isAvailable: boolean;
171-
state: string;
172-
name: string;
173-
udid: string;
174-
lastUsed?: string;
175-
}>
176-
>;
175+
devices: Record<string, SimulatorDeviceForSummary[]>;
177176
lastUpdated: Date;
178177
}
179178

@@ -211,12 +210,17 @@ export function extractSimulatorSummary(cachedList: CachedSimulatorList) {
211210
})),
212211
recentlyUsed: availableDevices
213212
.filter(d => d.lastUsed)
214-
.sort((a, b) => new Date(b.lastUsed!).getTime() - new Date(a.lastUsed!).getTime())
213+
.sort((a, b) => {
214+
// We already filtered for devices with lastUsed
215+
const aTime = a.lastUsed?.getTime() ?? 0;
216+
const bTime = b.lastUsed?.getTime() ?? 0;
217+
return bTime - aTime;
218+
})
215219
.slice(0, 3)
216220
.map(d => ({
217221
name: d.name,
218222
udid: d.udid,
219-
lastUsed: formatTimeAgo(d.lastUsed!),
223+
lastUsed: formatTimeAgo(d.lastUsed || new Date()),
220224
})),
221225
};
222226
}
@@ -288,6 +292,7 @@ interface SimulatorSummary {
288292
interface SimulatorFilters {
289293
deviceType?: string;
290294
runtime?: string;
295+
availability?: string;
291296
}
292297

293298
export function createProgressiveSimulatorResponse(

tests/__tests__/utils/response-cache.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,14 +452,14 @@ describe('extractSimulatorSummary', () => {
452452
udid: '123-456-789',
453453
state: 'Booted',
454454
isAvailable: true,
455-
lastUsed: '2023-12-01T10:00:00Z',
455+
lastUsed: new Date('2023-12-01T10:00:00Z'),
456456
},
457457
{
458458
name: 'iPhone 14',
459459
udid: '987-654-321',
460460
state: 'Shutdown',
461461
isAvailable: true,
462-
lastUsed: '2023-12-01T09:00:00Z',
462+
lastUsed: new Date('2023-12-01T09:00:00Z'),
463463
},
464464
],
465465
'com.apple.CoreSimulator.SimRuntime.iOS-17-0': [

0 commit comments

Comments
 (0)