refactor: extract types and convert logger modules to TypeScript#70
Merged
LingyuCoder merged 3 commits intomainfrom Jan 16, 2026
Merged
Conversation
There was a problem hiding this comment.
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.tsto a newsrc/types.tsfile for better code organization - Converted client-side logger modules (
Logger.ts,runtime.ts,createConsoleLogger.ts,tapable.ts,truncateArgs.ts) andsockjs-client/index.tsfrom 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
SyncBailHookfunction should have a return type annotation to ensure type safety. The return type should match the expected structure with acallmethod.
client-src/modules/logger/runtime.ts:40 - The
@ts-ignoredirective is suppressing TypeScript errors. Since the codebase is being converted to TypeScript, this should be replaced with proper typing. Consider defining a proper type forSyncBailHookor using@ts-expect-errorwith a comment explaining why the error is expected.
client-src/modules/logger/Logger.ts:49 - The
@ts-ignoredirective is suppressing TypeScript errors on thegetChildLoggerproperty. 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-errorwith an explanation.
client-src/modules/logger/Logger.ts:138 - Leftover JSDoc comment from the JavaScript version. This
@typeannotation 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request refactors the codebase by extracting type definitions into a dedicated
types.tsfile and converting logger-related JavaScript modules to TypeScript. The main improvements include:src/server.tsto a newsrc/types.tsfile to improve code organization and maintainabilityThese changes improve code maintainability and type safety without changing any runtime behavior.
Checklist