Skip to content

Fix TypeScript compilation error for y-websocket/bin/utils import#16

Merged
SMSDAO merged 2 commits intomainfrom
copilot/fix-typescript-error-yjs-server
Dec 13, 2025
Merged

Fix TypeScript compilation error for y-websocket/bin/utils import#16
SMSDAO merged 2 commits intomainfrom
copilot/fix-typescript-error-yjs-server

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 13, 2025

Description

TypeScript compilation failed because y-websocket (v1.5.0) doesn't provide type definitions for its internal /bin/utils module path, causing the import in server/yjs-server.ts to error.

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • 🎨 Style/UI update
  • ♻️ Code refactoring
  • ⚡ Performance improvement
  • ✅ Test update
  • 🔧 Configuration change
  • 🔒 Security fix

Related Issues

CI and CodeQL workflows failing with:

error TS7016: Could not find a declaration file for module 'y-websocket/bin/utils'

Changes Made

  • Created server/types/y-websocket-utils.d.ts with type declarations for setupWSConnection function
  • Updated .gitignore to exempt server/types/**/*.d.ts from the global *.d.ts ignore rule

Type declaration provides:

export interface SetupWSConnectionOptions {
  docName?: string;
  gc?: boolean;
}

export function setupWSConnection(
  ws: WebSocket,
  req: IncomingMessage,
  options?: SetupWSConnectionOptions
): void;

Testing

  • Unit tests pass
  • Integration tests pass
  • Manual testing completed
  • Browser testing (if applicable)

Test Coverage

  • TypeScript compilation: tsc --project tsconfig.server.json passes
  • Full build: npm run build completes without errors
  • CodeQL security scan: no vulnerabilities detected

Screenshots/Videos

N/A

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Deployment Notes

None. Type declarations are compile-time only.

Additional Context

The tsconfig.server.json already includes "server/**/*", so the new declaration file is automatically discovered. No configuration changes needed beyond the .gitignore exception.


Original prompt

Fix TypeScript compilation error in yjs-server.ts

Problem

Both CI and CodeQL workflows are failing with the following TypeScript error:

server/yjs-server.ts(3,35): error TS7016: Could not find a declaration file for module 'y-websocket/bin/utils'. 
'/home/runner/work/algo/algo/node_modules/y-websocket/bin/utils.js' implicitly has an 'any' type.

Root Cause

The code imports setupWSConnection from y-websocket/bin/utils, but TypeScript cannot find type definitions for this internal module path. The y-websocket package (v1.5.0) doesn't provide TypeScript definitions for its internal /bin/utils module.

Required Fix

Create a TypeScript declaration file to provide proper type definitions for the y-websocket/bin/utils module.

Solution Steps

  1. Create a new file server/types/y-websocket-utils.d.ts with proper type declarations for the setupWSConnection function and related types
  2. Ensure the TypeScript compiler configuration (tsconfig.server.json) includes the types directory
  3. The type declaration should properly type the setupWSConnection function that accepts:
    • ws parameter of type WebSocket (from 'ws' package)
    • req parameter (HTTP request)
    • options parameter with properties like docName (string) and gc (boolean)

Acceptance Criteria

  • TypeScript compilation succeeds for tsc --project tsconfig.server.json
  • CI workflow passes
  • CodeQL Security Scan workflow passes
  • No type errors in server/yjs-server.ts

Files to Modify/Create

  • Create: server/types/y-websocket-utils.d.ts
  • Potentially update: tsconfig.server.json (if needed to include the types directory)

This pull request was created as a result of the following prompt from Copilot chat.

Fix TypeScript compilation error in yjs-server.ts

Problem

Both CI and CodeQL workflows are failing with the following TypeScript error:

server/yjs-server.ts(3,35): error TS7016: Could not find a declaration file for module 'y-websocket/bin/utils'. 
'/home/runner/work/algo/algo/node_modules/y-websocket/bin/utils.js' implicitly has an 'any' type.

Root Cause

The code imports setupWSConnection from y-websocket/bin/utils, but TypeScript cannot find type definitions for this internal module path. The y-websocket package (v1.5.0) doesn't provide TypeScript definitions for its internal /bin/utils module.

Required Fix

Create a TypeScript declaration file to provide proper type definitions for the y-websocket/bin/utils module.

Solution Steps

  1. Create a new file server/types/y-websocket-utils.d.ts with proper type declarations for the setupWSConnection function and related types
  2. Ensure the TypeScript compiler configuration (tsconfig.server.json) includes the types directory
  3. The type declaration should properly type the setupWSConnection function that accepts:
    • ws parameter of type WebSocket (from 'ws' package)
    • req parameter (HTTP request)
    • options parameter with properties like docName (string) and gc (boolean)

Acceptance Criteria

  • TypeScript compilation succeeds for tsc --project tsconfig.server.json
  • CI workflow passes
  • CodeQL Security Scan workflow passes
  • No type errors in server/yjs-server.ts

Files to Modify/Create

  • Create: server/types/y-websocket-utils.d.ts
  • Potentially update: tsconfig.server.json (if needed to include the types directory)

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix TypeScript compilation error in yjs-server.ts Fix TypeScript compilation error for y-websocket/bin/utils import Dec 13, 2025
Copilot AI requested a review from SMSDAO December 13, 2025 05:59
@github-actions
Copy link
Copy Markdown

Review Update

@SMSDAO has submitted a review: approved

@SMSDAO SMSDAO marked this pull request as ready for review December 13, 2025 14:54
Copilot AI review requested due to automatic review settings December 13, 2025 14:54
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.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown

📢 New Pull Request Ready for Review

Title: Fix TypeScript compilation error for y-websocket/bin/utils import
Author: @Copilot
Branch: copilot/fix-typescript-error-yjs-servermain

Please review when you have a chance! 🚀

@github-advanced-security
Copy link
Copy Markdown

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@SMSDAO SMSDAO merged commit 38cbd95 into main Dec 13, 2025
23 of 33 checks passed
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.

4 participants