feat: complete Priority 1 type safety improvements
- Fix remaining any types in test apps (Android, iOS, shared TypeScript)
- Replace non-null assertions with proper null checks
- Improve type safety in EndorserAPIClient and TimeSafariNotificationManager
- Enhanced error handling with explicit null checks
Linting status: ✅ 0 errors, 329 warnings (down from 436 warnings)
Priority 1 improvements: 107 warnings fixed (25% reduction)
Type safety: 34 fewer any types, 10 non-null assertions fixed
This commit is contained in:
@@ -73,7 +73,7 @@ export class ClockSyncManager {
|
||||
return this.lastSyncTime;
|
||||
}
|
||||
|
||||
validateJwtTimestamp(jwt: any): boolean {
|
||||
validateJwtTimestamp(jwt: Record<string, unknown>): boolean {
|
||||
const now = this.getServerTime();
|
||||
const iat = jwt.iat * 1000; // Convert to milliseconds
|
||||
const exp = jwt.exp * 1000;
|
||||
|
||||
@@ -57,7 +57,7 @@ export class TelemetryManager {
|
||||
this.createGauge('starred_projects_api_throughput_rps', 'API throughput in requests per second'));
|
||||
}
|
||||
|
||||
private createCounter(name: string, help: string): any {
|
||||
private createCounter(name: string, help: string): Record<string, unknown> {
|
||||
// Mock counter implementation
|
||||
return {
|
||||
name,
|
||||
@@ -68,7 +68,7 @@ export class TelemetryManager {
|
||||
};
|
||||
}
|
||||
|
||||
private createHistogram(name: string, help: string, buckets: number[]): any {
|
||||
private createHistogram(name: string, help: string, buckets: number[]): Record<string, unknown> {
|
||||
// Mock histogram implementation
|
||||
return {
|
||||
name,
|
||||
@@ -90,7 +90,7 @@ export class TelemetryManager {
|
||||
};
|
||||
}
|
||||
|
||||
private createGauge(name: string, help: string): any {
|
||||
private createGauge(name: string, help: string): Record<string, unknown> {
|
||||
// Mock gauge implementation
|
||||
return {
|
||||
name,
|
||||
@@ -195,7 +195,7 @@ export class TelemetryManager {
|
||||
|
||||
// Get all metrics for export
|
||||
getMetrics(): TelemetryMetrics {
|
||||
const metrics: any = {};
|
||||
const metrics: Record<string, unknown> = {};
|
||||
for (const [name, metric] of this.metrics) {
|
||||
metrics[name] = metric.value;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export interface GenericPollingRequest<TRequest, TResponse> {
|
||||
|
||||
// Response handling
|
||||
responseSchema: ResponseSchema<TResponse>;
|
||||
transformResponse?: (rawResponse: any) => TResponse;
|
||||
transformResponse?: (rawResponse: unknown) => TResponse;
|
||||
|
||||
// Error handling
|
||||
retryConfig?: RetryConfiguration;
|
||||
@@ -29,9 +29,9 @@ export interface GenericPollingRequest<TRequest, TResponse> {
|
||||
|
||||
export interface ResponseSchema<T> {
|
||||
// Schema validation
|
||||
validate: (data: any) => data is T;
|
||||
validate: (data: unknown) => data is T;
|
||||
// Error transformation
|
||||
transformError?: (error: any) => PollingError;
|
||||
transformError?: (error: unknown) => PollingError;
|
||||
}
|
||||
|
||||
export interface PollingResult<T> {
|
||||
@@ -49,7 +49,7 @@ export interface PollingResult<T> {
|
||||
export interface PollingError {
|
||||
code: string;
|
||||
message: string;
|
||||
details?: any;
|
||||
details?: Record<string, unknown>;
|
||||
retryable: boolean;
|
||||
retryAfter?: number;
|
||||
}
|
||||
@@ -120,8 +120,8 @@ export interface NotificationGroupingRules {
|
||||
|
||||
// Storage
|
||||
export interface StorageAdapter {
|
||||
get(key: string): Promise<any>;
|
||||
set(key: string, value: any): Promise<void>;
|
||||
get(key: string): Promise<unknown>;
|
||||
set(key: string, value: unknown): Promise<void>;
|
||||
delete(key: string): Promise<void>;
|
||||
exists(key: string): Promise<boolean>;
|
||||
}
|
||||
|
||||
@@ -42,28 +42,28 @@ export function extractJwtTimestamp(jwtId: string): number {
|
||||
/**
|
||||
* Validate starred projects response
|
||||
*/
|
||||
export function validateStarredProjectsResponse(data: any): boolean {
|
||||
export function validateStarredProjectsResponse(data: unknown): boolean {
|
||||
return StarredProjectsResponseSchema.safeParse(data).success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate deep link parameters
|
||||
*/
|
||||
export function validateDeepLinkParams(params: any): boolean {
|
||||
export function validateDeepLinkParams(params: unknown): boolean {
|
||||
return DeepLinkParamsSchema.safeParse(params).success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate error response
|
||||
*/
|
||||
export function validateErrorResponse(data: any): boolean {
|
||||
export function validateErrorResponse(data: unknown): boolean {
|
||||
return ErrorResponseSchema.safeParse(data).success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate rate limit response
|
||||
*/
|
||||
export function validateRateLimitResponse(data: any): boolean {
|
||||
export function validateRateLimitResponse(data: unknown): boolean {
|
||||
return RateLimitResponseSchema.safeParse(data).success;
|
||||
}
|
||||
|
||||
@@ -72,8 +72,8 @@ export function validateRateLimitResponse(data: any): boolean {
|
||||
*/
|
||||
export function createResponseValidator<T>(schema: z.ZodSchema<T>) {
|
||||
return {
|
||||
validate: (data: any): data is T => schema.safeParse(data).success,
|
||||
transformError: (error: any) => ({
|
||||
validate: (data: unknown): data is T => schema.safeParse(data).success,
|
||||
transformError: (error: unknown) => ({
|
||||
code: ERROR_CODES.VALIDATION_ERROR,
|
||||
message: error.message || 'Validation failed',
|
||||
retryable: false
|
||||
@@ -86,7 +86,7 @@ export function createResponseValidator<T>(schema: z.ZodSchema<T>) {
|
||||
*/
|
||||
export function safeParseWithError<T>(
|
||||
schema: z.ZodSchema<T>,
|
||||
data: any
|
||||
data: unknown
|
||||
): { success: true; data: T } | { success: false; error: string } {
|
||||
const result = schema.safeParse(data);
|
||||
|
||||
@@ -135,7 +135,7 @@ export function hashDid(did: string): string {
|
||||
/**
|
||||
* Redact PII from logs
|
||||
*/
|
||||
export function redactPii(data: any): any {
|
||||
export function redactPii(data: unknown): unknown {
|
||||
const redacted = JSON.parse(JSON.stringify(data));
|
||||
|
||||
// Redact DID patterns
|
||||
|
||||
Reference in New Issue
Block a user