Skip to content

Fix TypeScript compilation errors in database client#92

Closed
Copilot wants to merge 4 commits into
copilot/create-integration-test-workflowfrom
copilot/fix-typescript-compiler-errors
Closed

Fix TypeScript compilation errors in database client#92
Copilot wants to merge 4 commits into
copilot/create-integration-test-workflowfrom
copilot/fix-typescript-compiler-errors

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 30, 2026

Fix TypeScript Compilation Errors in src/database/client.ts

Changes Completed

  • Analyze the issue and understand the requirements
  • Use type-only import for QueryResult to preserve explicit return type
  • Add explicit type annotation err: Error for pool error handler parameter
  • Fix pool configuration to use merged config ({ ...defaultConfig, ...config })
  • Add @types/node devDependency for database module compilation
  • Verify TypeScript compilation passes locally

Summary

Fixed TypeScript compilation errors in src/database/client.ts:

  1. Type-only import for QueryResult: Uses import type { QueryResult } to preserve explicit return type while eliminating unused import error
  2. Typed error handler: Added err: Error annotation for pool error event handler
  3. Config merging: Uses spread operator to allow partial config overrides instead of all-or-nothing replacement
  4. Added @types/node: Required devDependency for database module TypeScript compilation

CI Status Note

The current CI failures are pre-existing issues in the base branch:

  • Coverage threshold failures: Repository-wide coverage is 46% (need 80%) - not related to database client changes
  • Integration test failures: Schema initialization steps being skipped in workflow execution - base branch issue

My changes successfully compile locally and address all TypeScript errors in src/database/client.ts.

Original prompt

Problem

The CI build is failing with TypeScript compilation errors in src/database/client.ts:

  1. Line 1: QueryResult is imported but never used
  2. Line 27 (in the actual source, it's misplaced): Parameter err implicitly has an 'any' type in the pool error handler

Looking at the file structure, there's also a logical issue: the pool error handler (lines 24-27) is defined before the pool is actually created in the constructor, and it's outside the constructor entirely.

Required Changes

Fix src/database/client.ts:

  1. Move the pool error handler inside the constructor, after the pool is initialized
  2. Add explicit type annotation for the err parameter: err: Error
  3. The pool should be created with the merged config, then the error handler should be attached

The corrected structure should be:

constructor(config?: PoolConfig) {
  const defaultConfig: PoolConfig = {
    // ... config ...
  };

  this.pool = new Pool({ ...defaultConfig, ...config });

  // Handle pool errors
  this.pool.on('error', (err: Error) => {
    console.error('Unexpected database error:', err);
  });
}

Context

This is blocking PR #91 which adds integration test infrastructure. The failing job is at:
https://github.com/Violet-Site-Systems/VEXEL/actions/runs/21322549477/job/61374809539?pr=91

The file being modified is located at: src/database/client.ts with BlobSha: 96989db698e8779d190c5de006a47d45f2891315

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Remove unused QueryResult import
- Add explicit Error type annotation to pool error handler parameter
- Change pool initialization to use merged config (spread operator)

Co-authored-by: colleenpridemore <4281084+colleenpridemore@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix TypeScript compilation errors in database client Fix TypeScript compilation errors in database client Jan 30, 2026
@colleenpridemore colleenpridemore marked this pull request as ready for review January 30, 2026 19:04
Copilot AI review requested due to automatic review settings January 30, 2026 19:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes TypeScript build issues in the PostgreSQL DatabaseClient by cleaning up imports, tightening typing, and correcting pool configuration handling.

Changes:

  • Removed the unused QueryResult import from pg.
  • Corrected pool config initialization so user config overrides defaults via object spread.
  • Added an explicit Error type for the pool 'error' event handler parameter.

Comment thread src/database/client.ts Outdated
- Add 'import type { QueryResult }' instead of removing it entirely
- Restore explicit Promise<QueryResult<T>> return type on query method
- Maintains API documentation while avoiding unused import error

Co-authored-by: colleenpridemore <4281084+colleenpridemore@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@colleenpridemore colleenpridemore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok!

@colleenpridemore colleenpridemore marked this pull request as draft January 30, 2026 19:21
@colleenpridemore colleenpridemore marked this pull request as ready for review January 30, 2026 19:22
@colleenpridemore
Copy link
Copy Markdown
Contributor

@copilot apply changes based on the comments in this thread

- Required for TypeScript compilation of database module
- Fixes missing type definitions for process, console, etc.

Co-authored-by: colleenpridemore <4281084+colleenpridemore@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@colleenpridemore colleenpridemore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok!

Copy link
Copy Markdown
Contributor

@colleenpridemore colleenpridemore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checks still not passing

Copy link
Copy Markdown
Contributor

Superseded by #100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants