Skip to content

Commit ae30af9

Browse files
committed
fix: add explicit type assertions for dynamic imports to resolve CI linting errors
- Add type assertions for all await loader() calls in plugin-registry.ts - Type workflowModule as Record<string, unknown> in dynamic-tools.ts - Type resource as ResourceMeta in resources.ts - Fix potential undefined version in template-manager.ts with String() - Use nullish coalescing operator (??) instead of logical OR (||) These changes ensure TypeScript's type inference works consistently between local development and CI environments, preventing unsafe assignment and member access errors detected by ESLint's TypeScript rules.
1 parent 77028ca commit ae30af9

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

src/core/plugin-registry.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@ export async function loadWorkflowGroups(): Promise<Map<string, WorkflowGroup>>
2727
for (const [workflowName, loader] of Object.entries(WORKFLOW_LOADERS)) {
2828
try {
2929
// Dynamic import with code-splitting
30-
const workflowModule = await loader();
30+
const workflowModule = (await loader()) as {
31+
workflow?: WorkflowMeta;
32+
[key: string]: unknown;
33+
};
3134

3235
if (!workflowModule.workflow) {
3336
throw new Error(`Workflow metadata missing in ${workflowName}/index.js`);
3437
}
3538

3639
// Validate required fields
37-
const workflowMeta = workflowModule.workflow;
40+
const workflowMeta = workflowModule.workflow as WorkflowMeta;
3841
if (!workflowMeta.name || typeof workflowMeta.name !== 'string') {
3942
throw new Error(
4043
`Invalid workflow.name in ${workflowName}/index.js: must be a non-empty string`,
@@ -95,8 +98,8 @@ export async function getWorkflowMetadata(directoryName: string): Promise<Workfl
9598
// Fall back to loading the actual module
9699
const loader = WORKFLOW_LOADERS[directoryName as WorkflowName];
97100
if (loader) {
98-
const workflowModule = await loader();
99-
return workflowModule.workflow || null;
101+
const workflowModule = (await loader()) as { workflow?: WorkflowMeta };
102+
return workflowModule.workflow ?? null;
100103
}
101104

102105
return null;

src/core/resources.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export async function loadResources(): Promise<Map<string, ResourceMeta>> {
4141

4242
for (const [resourceName, loader] of Object.entries(RESOURCE_LOADERS)) {
4343
try {
44-
const resource = await loader();
44+
const resource = (await loader()) as ResourceMeta;
4545

4646
if (!resource.uri || !resource.handler || typeof resource.handler !== 'function') {
4747
throw new Error(`Invalid resource structure for ${resourceName}`);

src/utils/template-manager.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ export class TemplateManager {
6767
platform === 'iOS'
6868
? 'XCODEBUILD_MCP_IOS_TEMPLATE_VERSION'
6969
: 'XCODEBUILD_MCP_MACOS_TEMPLATE_VERSION';
70-
const version =
71-
process.env[envVarName] ?? process.env.XCODEBUILD_MCP_TEMPLATE_VERSION ?? defaultVersion;
70+
const version = String(
71+
process.env[envVarName] ?? process.env.XCODEBUILD_MCP_TEMPLATE_VERSION ?? defaultVersion,
72+
);
7273

7374
// Create temp directory for download
7475
const tempDir = join(tmpdir(), `xcodebuild-mcp-template-${randomUUID()}`);

0 commit comments

Comments
 (0)