Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing tsd on application #5406

Merged
merged 1 commit into from
Mar 10, 2025
Merged

fix: add missing tsd on application #5406

merged 1 commit into from
Mar 10, 2025

Conversation

fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Mar 10, 2025

Summary by CodeRabbit

  • Chores

    • Updated a development dependency to its latest minor release for improved stability.
  • New Features

    • Enhanced server operations with improved error handling and background processing capabilities, offering richer configuration support.
  • Tests

    • Refined configuration validations to strengthen testing reliability.

@fengmk2 fengmk2 requested a review from Copilot March 10, 2025 13:15
Copy link

coderabbitai bot commented Mar 10, 2025

Walkthrough

This pull request upgrades the @eggjs/mock dependency in the project and extends the type definitions in key parts of the codebase. The dependency version in package.json is bumped from ^6.0.6 to ^6.0.7. The EggCore interface in src/lib/application.ts now includes several new methods and properties to better support error handling, server events, background tasks, and configuration management. Additionally, the test file updates its import structure and type assertions to improve type safety.

Changes

File(s) Change Summary
package.json Updated the @eggjs/mock dependency version from ^6.0.6 to ^6.0.7 in devDependencies.
src/lib/.../application.ts Enhanced the EggCore interface by adding:
- onClientError(err: any, socket: Socket): void;
- onServer(server: http.Server): void;
- locals: Record<string, any>;
- runInBackground(scope: (ctx: Context) => Promise<void>, req?: unknown): void;
- toAsyncFunction(fn: …): …;
- dumpConfig(): void;
- get keys(): string[];
test/index.test-d.ts Added new imports for PowerPartial and EggAppConfig from ../src/index.js and introduced a new constant config with type assertions to check config.static?.gzip for improved type safety.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant EggCore
    participant Server
    participant BackgroundTask

    %% Server initialization:
    Server->>EggCore: Initialize server
    EggCore-->>Server: onServer(server)

    %% Processing client request:
    Client->>EggCore: Send request
    EggCore->>Server: Process request
    Server-->>EggCore: Return response
    alt Error Encountered
        EggCore->>EggCore: onClientError(error, socket)
    end

    %% Running a background task:
    EggCore->>BackgroundTask: runInBackground(task)
Loading

Possibly related PRs

  • fix: logger should not Partial #5393: This PR involves a dependency update for @eggjs/mock from ^6.0.5 to ^6.0.6, which is strongly related at the code level due to similar dependency version adjustments.

Poem

I'm a nimble rabbit on the code trail,
Hopping through updates without fail.
With new methods and versions crisp and neat,
The interfaces now make error handling sweet.
I twirl my ears and celebrate the bright code hue!
🐇✨ Happy coding from me to you!

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/lib/application.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-eggache".

(The package "eslint-plugin-eggache" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-eggache@latest --save-dev

The plugin "eslint-plugin-eggache" was referenced from the config file in ".eslintrc » eslint-config-egg/typescript » ./index.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

test/index.test-d.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-eggache".

(The package "eslint-plugin-eggache" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-eggache@latest --save-dev

The plugin "eslint-plugin-eggache" was referenced from the config file in ".eslintrc » eslint-config-egg/typescript » ./index.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1d5031e and 1864808.

📒 Files selected for processing (3)
  • package.json (1 hunks)
  • src/lib/application.ts (1 hunks)
  • test/index.test-d.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: Node.js / Test (windows-latest, 22)
  • GitHub Check: Node.js / Test (ubuntu-latest, 22)
  • GitHub Check: Node.js / Test (windows-latest, 22)
  • GitHub Check: Node.js / Test (windows-latest, 20)
  • GitHub Check: Node.js / Test (windows-latest, 18)
  • GitHub Check: Node.js / Test (ubuntu-latest, 22)
  • GitHub Check: Node.js / Test (ubuntu-latest, 20)
  • GitHub Check: Node.js / Test (ubuntu-latest, 18)
  • GitHub Check: Node.js / Test (macos-latest, 18)
  • GitHub Check: Node.js / Test (macos-latest, 20)
  • GitHub Check: Node.js / Test (macos-latest, 22)
🔇 Additional comments (4)
package.json (1)

58-58: Approved: Dependency version update

The update to @eggjs/mock from version ^6.0.6 to ^6.0.7 is a minor version bump that likely includes improved type definitions that complement the type declaration changes in the codebase.

test/index.test-d.ts (2)

12-13: Approved: Added necessary type imports

Adding the PowerPartial and EggAppConfig imports enhances type checking capabilities for configuration objects in the tests.


23-24: Approved: Added type assertion for configuration properties

The new type assertion properly verifies that the optional static gzip configuration property is correctly typed as boolean or undefined, improving type safety for configuration objects.

src/lib/application.ts (1)

297-308: Approved: Added missing type declarations to EggCore interface

This module augmentation adds important type declarations for methods and properties that already exist in the Application class but were missing from the EggCore interface. This improves TypeScript type checking and IDE support.

The declarations properly match the implementation signatures in the Application class:

  • onClientError and onServer handle error and server events
  • locals provides access to view-related variables
  • runInBackground enables background task execution
  • toAsyncFunction, dumpConfig, and keys accessor provide utility functionality

These type additions ensure consistent typing across the codebase.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Choose a reason for hiding this comment

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

PR Overview

This PR adds missing TypeScript declaration definitions to extend the EggCore interface and updates test types accordingly.

  • Extend EggCore with additional overrides and utilities in the application module.
  • Update test imports and add type assertions for new application configuration types.

Reviewed Changes

File Description
src/lib/application.ts Adds TypeScript declarations to extend EggCore with new overrides
test/index.test-d.ts Updates test type imports and assertions to include EggAppConfig and PowerPartial

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

Copy link

codecov bot commented Mar 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.93%. Comparing base (8e433d9) to head (1864808).
Report is 3 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #5406      +/-   ##
==========================================
+ Coverage   94.91%   94.93%   +0.01%     
==========================================
  Files          40       40              
  Lines        3774     3787      +13     
  Branches      352      380      +28     
==========================================
+ Hits         3582     3595      +13     
  Misses        192      192              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@fengmk2 fengmk2 merged commit 8fa4aec into next Mar 10, 2025
32 of 34 checks passed
@fengmk2 fengmk2 deleted the add-missing-tsd branch March 10, 2025 16:05
fengmk2 pushed a commit that referenced this pull request Mar 10, 2025
[skip ci]

## [4.0.10](v4.0.9...v4.0.10) (2025-03-10)

### Bug Fixes

* add missing tsd on application ([#5406](#5406)) ([8fa4aec](8fa4aec))
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.

1 participant