Skip to content

Conversation

@LingyuCoder
Copy link
Contributor

Summary

This pull request refactors the codebase by extracting type definitions into a dedicated types.ts file and converting logger-related JavaScript modules to TypeScript. The main improvements include:

  • Type extraction: Moved all type definitions from src/server.ts to a new src/types.ts file to improve code organization and maintainability
  • TypeScript migration: Converted logger modules from JavaScript to TypeScript for better type safety and developer experience
  • Code cleanup: Simplified type imports and improved code structure

These changes improve code maintainability and type safety without changing any runtime behavior.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings January 16, 2026 07:11
Copy link

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

This PR refactors the codebase by extracting type definitions to a dedicated types.ts file and converting logger-related modules from JavaScript to TypeScript. The changes improve code organization and type safety while maintaining runtime behavior.

Changes:

  • Extracted all type definitions from src/server.ts to a new src/types.ts file for better code organization
  • Converted client-side logger modules (Logger.ts, runtime.ts, createConsoleLogger.ts, tapable.ts, truncateArgs.ts) and sockjs-client/index.ts from JavaScript to TypeScript
  • Updated build configuration to support TypeScript compilation with SWC loader

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/types.ts New file containing all extracted type definitions from server.ts
src/server.ts Simplified to import types from types.ts instead of defining them inline
src/config.ts Updated imports to use types.ts instead of server.ts
src/servers/WebsocketServer.ts Updated type imports to reference types.ts
src/servers/SockJSServer.ts Updated type imports and removed JSDoc comments
src/servers/BaseServer.ts Updated type imports and removed JSDoc comments
scripts/build-client-modules.cjs Added TypeScript support with resolve extensions and SWC loader configuration
client-src/modules/logger/Logger.ts Converted from JavaScript to TypeScript with proper type annotations
client-src/modules/logger/runtime.ts Converted from JavaScript to TypeScript with ES module exports
client-src/modules/logger/createConsoleLogger.ts Converted from JavaScript to TypeScript with proper type definitions
client-src/modules/logger/tapable.ts Converted from JavaScript to TypeScript as a mock SyncBailHook implementation
client-src/modules/logger/truncateArgs.ts Converted from JavaScript to TypeScript with type annotations
client-src/modules/logger/index.ts Removed TypeScript ignore directives after conversion
client-src/modules/types.ts New file with EXPECTED_ANY type for client-side logger
client-src/modules/sockjs-client/index.ts Converted from JavaScript to TypeScript as a re-export
client-src/utils/ansiHTML.ts Removed redundant JSDoc comments after type annotations exist
client-src/index.ts Simplified inline arrow function with proper TypeScript typing
Comments suppressed due to low confidence (4)

client-src/modules/logger/tapable.ts:15

  • The SyncBailHook function should have a return type annotation to ensure type safety. The return type should match the expected structure with a call method.
    client-src/modules/logger/runtime.ts:40
  • The @ts-ignore directive is suppressing TypeScript errors. Since the codebase is being converted to TypeScript, this should be replaced with proper typing. Consider defining a proper type for SyncBailHook or using @ts-expect-error with a comment explaining why the error is expected.
    client-src/modules/logger/Logger.ts:49
  • The @ts-ignore directive is suppressing TypeScript errors on the getChildLogger property. Since this is a TypeScript migration, proper typing should be provided instead of using @ts-ignore. Consider defining the property type correctly or using @ts-expect-error with an explanation.
    client-src/modules/logger/Logger.ts:138
  • Leftover JSDoc comment from the JavaScript version. This @type annotation is now redundant since TypeScript infers the type from the property declaration, and should be removed.

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

@LingyuCoder LingyuCoder merged commit d3fa033 into main Jan 16, 2026
4 checks passed
@LingyuCoder LingyuCoder deleted the refactor/extract-types-and-convert-to-typescript branch January 16, 2026 09:41
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.

2 participants