Description
Enable TypeScript strict mode in tsconfig.json and fix all resulting type issues. The codebase currently has several @ts-ignore comments and may have implicit any types that should be properly typed.
What needs to be done
-
Enable strict mode in tsconfig.json:
{
"compilerOptions": {
"strict": true,
// This enables:
// "noImplicitAny": true,
// "strictNullChecks": true,
// "strictFunctionTypes": true,
// "strictBindCallApply": true,
// "strictPropertyInitialization": true,
// "noImplicitThis": true,
// "alwaysStrict": true
}
}
-
Fix all type errors that arise
-
Remove @ts-ignore comments where possible
-
Add proper types for runtime-specific globals (Bun, Deno)
Why this matters
TypeScript strict mode catches many bugs at compile time:
- Null/undefined access errors
- Incorrect function signatures
- Missing error handling
- Type mismatches
Current @ts-ignore usage hides potential issues:
- Line 132, 284, 597, 602 in
src/server.ts - Runtime global detection
Implementation considerations
⚠️ Note: This feature requires critical thinking during implementation. Consider:
-
Runtime types: Instead of @ts-ignore for Bun/Deno globals, should we create proper type definitions or use type guards?
-
Breaking changes: Strict mode might reveal API issues. Should we fix them (breaking change) or maintain compatibility?
-
Alternative approach: Enable strict flags one at a time to make the migration manageable
-
Type assertions vs type guards: When fixing errors, prefer type guards over assertions for runtime safety
-
Any migration: Instead of jumping to strict types, should we first migrate from any to unknown?
Current problem areas
// src/server.ts:132
// @ts-ignore - Bun global not available in TypeScript definitions
this.server = Bun.serve({
port,
hostname,
fetch: (request: Request) => this.handleRequest(request),
});
Suggested solutions
Option 1: Ambient declarations
// src/types/runtime.d.ts
declare global {
const Bun: {
serve(options: {
port: number;
hostname: string;
fetch: (request: Request) => Response | Promise<Response>;
}): {
stop(): void;
port: number;
};
} | undefined;
const Deno: {
serve(
options: { port: number; hostname: string; signal?: AbortSignal },
handler: (request: Request) => Response | Promise<Response>
): { finished: Promise<void> };
} | undefined;
}
Option 2: Runtime detection with type guards
function isBunRuntime(): boolean {
return typeof globalThis.Bun !== "undefined";
}
function isDenoRuntime(): boolean {
return typeof globalThis.Deno !== "undefined";
}
if (isBunRuntime()) {
// TypeScript knows Bun exists here
const server = (globalThis as any).Bun.serve({...});
}
Option 3: Factory pattern
interface RuntimeServer {
start(options: ServerOptions): Promise<void>;
stop(): Promise<void>;
}
class BunServer implements RuntimeServer {
// Bun-specific implementation
}
class DenoServer implements RuntimeServer {
// Deno-specific implementation
}
class NodeServer implements RuntimeServer {
// Node-specific implementation
}
function createServer(): RuntimeServer {
if (typeof globalThis.Bun !== "undefined") {
return new BunServer();
}
// ...
}
Migration strategy
- Create type definitions for runtime globals
- Enable
noImplicitAny first
- Fix implicit any types
- Enable
strictNullChecks
- Fix null/undefined issues
- Enable remaining strict flags
- Remove all
@ts-ignore comments
Expected type issues to fix
- Implicit any in error handlers
- Possible null/undefined access
- Missing return types
- Untyped function parameters
- Type assertions that could be type guards
Skills required
- TypeScript (advanced)
- Type system understanding
- Runtime environment differences
- Refactoring skills
Difficulty
Easy to Medium - Depends on how many type issues exist
Description
Enable TypeScript strict mode in
tsconfig.jsonand fix all resulting type issues. The codebase currently has several@ts-ignorecomments and may have implicitanytypes that should be properly typed.What needs to be done
Enable strict mode in
tsconfig.json:{ "compilerOptions": { "strict": true, // This enables: // "noImplicitAny": true, // "strictNullChecks": true, // "strictFunctionTypes": true, // "strictBindCallApply": true, // "strictPropertyInitialization": true, // "noImplicitThis": true, // "alwaysStrict": true } }Fix all type errors that arise
Remove
@ts-ignorecomments where possibleAdd proper types for runtime-specific globals (Bun, Deno)
Why this matters
TypeScript strict mode catches many bugs at compile time:
Current
@ts-ignoreusage hides potential issues:src/server.ts- Runtime global detectionImplementation considerations
Runtime types: Instead of
@ts-ignorefor Bun/Deno globals, should we create proper type definitions or use type guards?Breaking changes: Strict mode might reveal API issues. Should we fix them (breaking change) or maintain compatibility?
Alternative approach: Enable strict flags one at a time to make the migration manageable
Type assertions vs type guards: When fixing errors, prefer type guards over assertions for runtime safety
Any migration: Instead of jumping to strict types, should we first migrate from
anytounknown?Current problem areas
Suggested solutions
Option 1: Ambient declarations
Option 2: Runtime detection with type guards
Option 3: Factory pattern
Migration strategy
noImplicitAnyfirststrictNullChecks@ts-ignorecommentsExpected type issues to fix
Skills required
Difficulty
Easy to Medium - Depends on how many type issues exist