109 lines
2.7 KiB
Markdown
109 lines
2.7 KiB
Markdown
|
|
# Quick Fixes Needed for TypeScript Strict Mode
|
||
|
|
|
||
|
|
## Import Fixes (Use `import type` for verbatimModuleSyntax)
|
||
|
|
|
||
|
|
### Files to fix:
|
||
|
|
|
||
|
|
1. **ts/core/connection/connection-manager.ts**
|
||
|
|
```typescript
|
||
|
|
// Change:
|
||
|
|
import { ElasticsearchConfig } from '../config/types.js';
|
||
|
|
import { HealthCheckResult, HealthStatus } from './health-check.js';
|
||
|
|
|
||
|
|
// To:
|
||
|
|
import type { ElasticsearchConfig } from '../config/types.js';
|
||
|
|
import type { HealthCheckResult } from './health-check.js';
|
||
|
|
import { HealthStatus } from './health-check.js';
|
||
|
|
```
|
||
|
|
|
||
|
|
2. **ts/core/errors/elasticsearch-error.ts**
|
||
|
|
```typescript
|
||
|
|
// Change:
|
||
|
|
import { ErrorCode, ErrorContext } from './types.js';
|
||
|
|
|
||
|
|
// To:
|
||
|
|
import { ErrorCode } from './types.js';
|
||
|
|
import type { ErrorContext } from './types.js';
|
||
|
|
```
|
||
|
|
|
||
|
|
3. **ts/core/errors/retry-policy.ts**
|
||
|
|
```typescript
|
||
|
|
// Change:
|
||
|
|
import { RetryConfig, RetryStrategy } from './types.js';
|
||
|
|
|
||
|
|
// To:
|
||
|
|
import type { RetryConfig, RetryStrategy } from './types.js';
|
||
|
|
```
|
||
|
|
|
||
|
|
4. **ts/domain/documents/document-manager.ts**
|
||
|
|
```typescript
|
||
|
|
// Change:
|
||
|
|
import {
|
||
|
|
DocumentWithMeta,
|
||
|
|
SessionConfig,
|
||
|
|
SnapshotProcessor,
|
||
|
|
SnapshotMeta,
|
||
|
|
IteratorOptions,
|
||
|
|
} from './types.js';
|
||
|
|
|
||
|
|
// To:
|
||
|
|
import type {
|
||
|
|
DocumentWithMeta,
|
||
|
|
SessionConfig,
|
||
|
|
SnapshotProcessor,
|
||
|
|
SnapshotMeta,
|
||
|
|
IteratorOptions,
|
||
|
|
} from './types.js';
|
||
|
|
```
|
||
|
|
|
||
|
|
## Tracing undefined issue (ts/core/observability/tracing.ts:315-317)
|
||
|
|
|
||
|
|
```typescript
|
||
|
|
// In TracingProvider.createSpan(), change:
|
||
|
|
const span = this.tracer.startSpan(name, {
|
||
|
|
...attributes,
|
||
|
|
'service.name': this.config.serviceName,
|
||
|
|
...(this.config.serviceVersion && { 'service.version': this.config.serviceVersion }),
|
||
|
|
});
|
||
|
|
|
||
|
|
// To:
|
||
|
|
const spanAttributes = {
|
||
|
|
...attributes,
|
||
|
|
'service.name': this.config.serviceName || 'elasticsearch-client',
|
||
|
|
};
|
||
|
|
if (this.config.serviceVersion) {
|
||
|
|
spanAttributes['service.version'] = this.config.serviceVersion;
|
||
|
|
}
|
||
|
|
const span = this.tracer.startSpan(name, spanAttributes);
|
||
|
|
```
|
||
|
|
|
||
|
|
## Generic Type Constraints for Elasticsearch Client
|
||
|
|
|
||
|
|
In **ts/domain/documents/document-manager.ts**, add constraint:
|
||
|
|
|
||
|
|
```typescript
|
||
|
|
// Change class definition:
|
||
|
|
export class DocumentManager<T = unknown> {
|
||
|
|
|
||
|
|
// To:
|
||
|
|
export class DocumentManager<T extends Record<string, any> = Record<string, any>> {
|
||
|
|
```
|
||
|
|
|
||
|
|
This ensures T is always an object type compatible with Elasticsearch operations.
|
||
|
|
|
||
|
|
## Alternative: Relax Strict Mode Temporarily
|
||
|
|
|
||
|
|
If immediate fixes are needed, you can temporarily relax some strict checks in tsconfig.json:
|
||
|
|
|
||
|
|
```json
|
||
|
|
{
|
||
|
|
"compilerOptions": {
|
||
|
|
// Comment out temporarily:
|
||
|
|
// "verbatimModuleSyntax": true,
|
||
|
|
// "noUncheckedIndexedAccess": true,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
But the proper fix is to address the imports and type issues as outlined above.
|