Skip to content

chore: remove unnecessary type assertions#5802

Merged
chenjiahan merged 2 commits intomainfrom
fix_no-unnecessary-type-assertion_0809
Aug 9, 2025
Merged

chore: remove unnecessary type assertions#5802
chenjiahan merged 2 commits intomainfrom
fix_no-unnecessary-type-assertion_0809

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

Summary

  • Removed unnecessary type assertions
  • Removed the rule disabling @typescript-eslint/no-unnecessary-type-assertion in rslint.json

Checklist

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

Copilot AI review requested due to automatic review settings August 9, 2025 02:02
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

This PR removes unnecessary type assertions from the codebase and re-enables the corresponding ESLint rule. The changes improve type safety by relying on TypeScript's inference rather than explicit assertions.

  • Removed the ESLint rule exception for @typescript-eslint/no-unnecessary-type-assertion
  • Eliminated type assertions where TypeScript can infer the correct types
  • Removed unused type imports that were only needed for the assertions

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
rslint.json Re-enabled the no-unnecessary-type-assertion ESLint rule
packages/plugin-vue/src/splitChunks.ts Removed type assertion and unused import
packages/plugin-react/src/splitChunks.ts Removed type assertion and unused import
packages/core/src/server/runner/esm.ts Removed non-null assertions on file parameter
packages/core/src/server/runner/basic.ts Removed non-null assertion on array access

const p = Array.isArray(modulePath)
? modulePath
: modulePath.split('?')[0]!;
: modulePath.split('?')[0];
Copy link

Copilot AI Aug 9, 2025

Choose a reason for hiding this comment

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

Removing the non-null assertion here could cause a runtime error. The split('?')[0] operation could return undefined if the array is empty, which would break the subsequent code. Consider adding proper validation or keeping the assertion with a runtime check.

Suggested change
: modulePath.split('?')[0];
: (typeof modulePath === 'string' ? (modulePath.split('?')[0] ?? '') : '');

Copilot uses AI. Check for mistakes.
@netlify
Copy link
Copy Markdown

netlify bot commented Aug 9, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 0e036e3
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/6896ad881c6e15000891f27e
😎 Deploy Preview https://deploy-preview-5802--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 75 (🟢 up 3 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@chenjiahan chenjiahan merged commit 0023c6c into main Aug 9, 2025
11 checks passed
@chenjiahan chenjiahan deleted the fix_no-unnecessary-type-assertion_0809 branch August 9, 2025 02:14
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