Skip to content

chore(ts): enable TypeScript strict mode and fix all resulting type errors #366

@coderabbitai

Description

@coderabbitai

Overview

Enable TypeScript strict: true in tsconfig.json and resolve all resulting type errors across the codebase to enforce full type safety.

Background

The repository coding guidelines require TypeScript strict mode and prohibit any types. Currently, tsconfig.json sets "noImplicitAny": false and "strictBindCallApply": false, leaving several strict checks disabled. Enabling strict: true was deferred from PR #359 (dependency update / TypeScript 6.0 migration) as it is out of scope for that change.

Proposed Changes

   "compilerOptions": {
+    "strict": true,
-    "strictNullChecks": true,
-    "noImplicitAny": false,
-    "strictBindCallApply": false,
   }
  1. Add "strict": true to tsconfig.json (this supersedes the individual flags above).
  2. Fix all TypeScript errors surfaced by enabling strict mode across src/**/*.ts and tests/**/*.ts.

Known hotspot: as any casts in ConnectionManager.test.ts (ex-#367)

tests/unit/services/ConnectionManager.test.ts contains approximately 40 occurrences of as any casts used to access private members of ConnectionManager (e.g., (manager as any).instanceInfo, (manager as any).schemaInfo, spying on doIntrospection, etc.).

Proposed solution for test as any

Define a small test-only interface (TestableConnectionManager) that declares the private fields and methods accessed in tests, then cast via unknown:

type TestableConnectionManager = {
  doIntrospection: (instanceUrl: string) => Promise<void>;
  instanceInfo: { version: string; tier: string } | null;
  schemaInfo: { workItemWidgetTypes: unknown[] } | null;
  introspectedInstanceUrl: string | null;
  introspectionPromises: Map<string, Promise<void>>;
  tokenScopeInfo: unknown;
  client: unknown;
  versionDetector: unknown;
  schemaIntrospector: unknown;
  isInitialized: boolean;
};

const managerInternal = manager as unknown as TestableConnectionManager;

Replace all (manager as any).* accesses with managerInternal.* and update spy targets accordingly.

Affected lines in ConnectionManager.test.ts

Known occurrences include lines 28, 121, 144, 171, 198, 225, 263–268, 279–284, 291, 301–303, 322–327, 330, 336–338, 344, 351–356, 359, 365, 380–382 (and others throughout the file).

References

/cc @polaz

Metadata

Metadata

Assignees

Labels

enhancementNew feature, new MCP tool, new capability

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions