Skip to content

🧹 [Code Health] Remove explicit @ts-expect-error in cardLayout tests#175

Open
is0692vs wants to merge 2 commits intomainfrom
code-health-remove-ts-expect-error-5155412759614690720
Open

🧹 [Code Health] Remove explicit @ts-expect-error in cardLayout tests#175
is0692vs wants to merge 2 commits intomainfrom
code-health-remove-ts-expect-error-5155412759614690720

Conversation

@is0692vs
Copy link
Copy Markdown
Contributor

@is0692vs is0692vs commented Apr 17, 2026

🎯 What: Replaced the explicit @ts-expect-error in src/lib/__tests__/cardLayout.test.ts with as unknown as CardBlockId to handle intentional type-bypass for runtime validation testing. Also updated imports.
💡 Why: Relying on @ts-expect-error shows a gap between type checking and runtime validation, and suppresses potential real compilation errors. Using a deliberate double cast achieves the exact same invalid-input runtime test securely.
Verification: Verified that tests in the modified file still pass and overall test coverage is maintained. Also confirmed that the full test suite runs without regression, and that linter and type-checker both pass cleanly.
Result: Improved test code maintainability and correctness while keeping the existing runtime safety check behavior completely intact.


PR created automatically by Jules for task 5155412759614690720 started by @is0692vs

Greptile Summary

テストコードの型バイパス手法を @ts-expect-error から as unknown as CardBlockId ダブルキャストに統一し、あわせて CardBlockId をインポートにインライン型参照から直接インポートへ変更するクリーンアップ PR です。テストロジックや実行時の振る舞いに変更はなく、既存の toggleBlockVisibility テスト(81行目)で使われていたパターンに moveBlock テストを合わせる形になっています。

Confidence Score: 5/5

マージ安全。テストロジックに変更はなく、P2 のスタイル指摘のみ。

変更はすべてテストコードのスタイル統一であり、実装コードや実行時の振る舞いへの影響はゼロ。P0/P1 の問題は存在しない。

特に注意が必要なファイルはありません。

Important Files Changed

Filename Overview
src/lib/tests/cardLayout.test.ts CardBlockId を直接インポートし、@ts-expect-erroras unknown as CardBlockId ダブルキャストに統一。テストロジックに変更はなく、動作は維持されている。

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["無効な blockId を渡してテスト"] --> B{型バイパス手法}
    B -- "変更前 (@ts-expect-error)" --> C["TypeScript が型エラーを抑制\n将来シグネチャ変更時は警告あり"]
    B -- "変更後 (as unknown as CardBlockId)" --> D["TypeScript の型チェックを完全スキップ\n将来シグネチャ変更時も警告なし"]
    C --> E[moveBlock / toggleBlockVisibility 呼び出し]
    D --> E
    E --> F["expect(moved).toBe(layout) / expect(next.blocks).toEqual(layout.blocks)"]
Loading
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/lib/__tests__/cardLayout.test.ts
Line: 108

Comment:
**`@ts-expect-error` の方が型安全性が高い**

`as unknown as CardBlockId` は TypeScript の型チェックを完全に無効化するため、将来 `moveBlock` のシグネチャが `string` を受け入れるように変更されても、このキャストは警告なしにコンパイルされ続けます。一方 `@ts-expect-error` は、次の行に型エラーが存在しなくなると「Unused '@ts-expect-error' directive」エラーを発生させるため、シグネチャ変更を検知できます。

`as unknown as` パターンでの統一自体は一貫性があり理解できますが、PR 説明の「`@ts-expect-error` より安全」という主張は実際には逆で、`@ts-expect-error` の方がより厳密な型安全性を提供します。

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "🧹 [Code Health] Remove explicit @ts-exp..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
github-user-summary Ready Ready Preview, Comment Apr 17, 2026 8:40am

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 17, 2026

Warning

Rate limit exceeded

@is0692vs has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes and 59 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 20 minutes and 59 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4c2e450a-d530-4cf6-aa79-5b661a286665

📥 Commits

Reviewing files that changed from the base of the PR and between 3be157d and 4f47e0e.

📒 Files selected for processing (1)
  • src/lib/__tests__/cardLayout.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch code-health-remove-ts-expect-error-5155412759614690720

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment thread src/lib/__tests__/cardLayout.test.ts
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the cardLayout.test.ts file to import CardBlockId and replaces inline type imports and @ts-expect-error directives with explicit type casting for invalid block IDs. The reviewer suggests reverting the use of type casting in favor of @ts-expect-error for testing invalid inputs to maintain type safety and better assertion of invalidity, which would also allow for the removal of the CardBlockId import.

Comment thread src/lib/__tests__/cardLayout.test.ts
Comment thread src/lib/__tests__/cardLayout.test.ts
Comment thread src/lib/__tests__/cardLayout.test.ts
Co-authored-by: is0692vs <135803462+is0692vs@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant