refactor: improve type safety by removing 'as any' casts
Created database.ts with proper database result types and replaced 38+ 'as any' casts throughout the codebase with proper type annotations. Changes: - Created src/types/database.ts with TableColumnInfo, IndexInfo, and database record types - Fixed all type casts in SessionStore.ts (migrations, query results) - Fixed type casts in SessionSearch.ts, SettingsManager.ts, SettingsRoutes.ts - Improved MCP server JSON schema typing All builds pass and worker service runs successfully. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -37,7 +37,7 @@ export class SettingsManager {
|
||||
for (const row of rows) {
|
||||
const key = row.key as keyof ViewerSettings;
|
||||
if (key in settings) {
|
||||
(settings as any)[key] = JSON.parse(row.value);
|
||||
settings[key] = JSON.parse(row.value) as ViewerSettings[typeof key];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,9 @@ import {
|
||||
OBSERVATION_TYPES,
|
||||
OBSERVATION_CONCEPTS,
|
||||
DEFAULT_OBSERVATION_TYPES_STRING,
|
||||
DEFAULT_OBSERVATION_CONCEPTS_STRING
|
||||
DEFAULT_OBSERVATION_CONCEPTS_STRING,
|
||||
ObservationType,
|
||||
ObservationConcept
|
||||
} from '../../../../constants/observation-metadata.js';
|
||||
|
||||
export class SettingsRoutes {
|
||||
@@ -348,7 +350,7 @@ export class SettingsRoutes {
|
||||
if (settings.CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES) {
|
||||
const types = settings.CLAUDE_MEM_CONTEXT_OBSERVATION_TYPES.split(',').map((t: string) => t.trim());
|
||||
for (const type of types) {
|
||||
if (type && !OBSERVATION_TYPES.includes(type as any)) {
|
||||
if (type && !OBSERVATION_TYPES.includes(type as ObservationType)) {
|
||||
return { valid: false, error: `Invalid observation type: ${type}. Valid types: ${OBSERVATION_TYPES.join(', ')}` };
|
||||
}
|
||||
}
|
||||
@@ -358,7 +360,7 @@ export class SettingsRoutes {
|
||||
if (settings.CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS) {
|
||||
const concepts = settings.CLAUDE_MEM_CONTEXT_OBSERVATION_CONCEPTS.split(',').map((c: string) => c.trim());
|
||||
for (const concept of concepts) {
|
||||
if (concept && !OBSERVATION_CONCEPTS.includes(concept as any)) {
|
||||
if (concept && !OBSERVATION_CONCEPTS.includes(concept as ObservationConcept)) {
|
||||
return { valid: false, error: `Invalid observation concept: ${concept}. Valid concepts: ${OBSERVATION_CONCEPTS.join(', ')}` };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user