refactor: replace @ts-ignore with @ts-expect-error for stricter type suppression#2581
refactor: replace @ts-ignore with @ts-expect-error for stricter type suppression#2581nperez0111 wants to merge 1 commit intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughTypeScript suppression directives are being updated across five files in three packages, replacing Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
5bea0e4 to
b0badc9
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/xl-ai/src/api/formats/tests/sharedTestCases.ts`:
- Around line 23-24: Move the TypeScript suppression so it directly precedes the
function signature for matchFileSnapshot: remove or reorder the two comments so
that the `@ts-expect-error` is immediately above async function
matchFileSnapshot(data: any, postFix = "") (and keep or merge the
eslint-disable-next-line comment appropriately), ensuring the `@ts-expect-error`
applies to the unused postFix parameter.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6ae2b18c-9ab1-430b-8d42-4c2c3acad020
📒 Files selected for processing (6)
docs/components/FadeIn.tsxpackages/core/src/editor/BlockNoteEditor.tspackages/core/src/schema/inlineContent/types.tspackages/xl-ai/src/api/formats/tests/sharedTestCases.tspackages/xl-ai/src/prosemirror/rebaseTool.tspackages/xl-odt-exporter/src/odt/odtExporter.test.ts
| // @ts-expect-error | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify potentially fragile ts-expect-error placement patterns.
# Expected result after fix: no matches.
rg -nP -U '//\s*@ts-expect-error[^\n]*\n\s*//\s*eslint-disable-next-line' \
packages/xl-ai/src/api/formats/tests/sharedTestCases.tsRepository: TypeCellOS/BlockNote
Length of output: 151
🏁 Script executed:
sed -n '20,35p' packages/xl-ai/src/api/formats/tests/sharedTestCases.ts | cat -nRepository: TypeCellOS/BlockNote
Length of output: 671
🏁 Script executed:
# Check if matchFileSnapshot is used in the file
rg -n "matchFileSnapshot" packages/xl-ai/src/api/formats/tests/sharedTestCases.ts
# Also check broader codebase usage
rg -n "matchFileSnapshot" packages/xl-ai/src/api/formats/tests/ | head -20Repository: TypeCellOS/BlockNote
Length of output: 449
🏁 Script executed:
# Check if the function is exported and used elsewhere
rg -n "matchFileSnapshot" --type ts --type tsx packages/xl-ai/ | grep -v "^packages/xl-ai/src/api/formats/tests/sharedTestCases.ts"
# Check the exports of the test file
grep -n "export" packages/xl-ai/src/api/formats/tests/sharedTestCases.tsRepository: TypeCellOS/BlockNote
Length of output: 152
🏁 Script executed:
# Let's look at the complete function and broader context
sed -n '20,50p' packages/xl-ai/src/api/formats/tests/sharedTestCases.ts | cat -nRepository: TypeCellOS/BlockNote
Length of output: 1122
🏁 Script executed:
# Check TypeScript version and configuration
cat packages/xl-ai/tsconfig.json
# Also check if there are any TypeScript errors being suppressed here by looking at the imports
sed -n '1,22p' packages/xl-ai/src/api/formats/tests/sharedTestCases.ts | cat -nRepository: TypeCellOS/BlockNote
Length of output: 2155
🏁 Script executed:
# Let's check if the function is actually being used or if it's dead code
# Also check if there's documentation about what error this is suppressing
rg -B5 -A15 "matchFileSnapshot" packages/xl-ai/src/api/formats/tests/sharedTestCases.ts | head -40Repository: TypeCellOS/BlockNote
Length of output: 1492
🏁 Script executed:
# Let's verify if the function actually has a TypeScript error that needs suppressing
# by looking at what toMatchFileSnapshot is
rg -n "toMatchFileSnapshot" packages/xl-ai/
# Also check the vitest types to understand if there's a real type error here
rg -n "toMatchFileSnapshot" --type-listRepository: TypeCellOS/BlockNote
Length of output: 571
🏁 Script executed:
# Check what type error this `@ts-expect-error` is supposed to suppress
# Let's examine the vitest types to understand toMatchFileSnapshot
find . -name "*.d.ts" -o -name "*.ts" | xargs rg "toMatchFileSnapshot" | head -5
# Also check package.json to see vitest version
cat packages/xl-ai/package.json | grep -A2 -B2 "vitest"Repository: TypeCellOS/BlockNote
Length of output: 1497
🏁 Script executed:
# Check if there are any TypeScript or compilation errors with the current setup
# Let's look at whether this is actually a dead code issue
grep -B10 -A20 "matchFileSnapshot" packages/xl-ai/src/api/formats/tests/sharedTestCases.ts | tail -30
# Also check if there's a tsconfig that would show noUnusedLocals
cat packages/xl-ai/tsconfig.json | grep -i "unused"Repository: TypeCellOS/BlockNote
Length of output: 1226
🏁 Script executed:
# Let's verify if there's actually a TypeScript error being suppressed here
# by checking if the `@ts-expect-error` is actually needed or if it's broken
# First, let's see if there are any similar patterns in the codebase
rg -n "@ts-expect-error" packages/xl-ai/src/ | head -10
# Also check if there's a pattern where `@ts-expect-error` and eslint-disable are combined differently
rg -B1 -A1 "@ts-expect-error" packages/xl-ai/src/ | head -40Repository: TypeCellOS/BlockNote
Length of output: 1390
Move @ts-expect-error directly before the function declaration to ensure the suppression is effective.
The @ts-expect-error directive (line 23) is separated from the function declaration by an ESLint comment (line 24), which can prevent TypeScript from correctly associating the suppression with the unused postFix parameter. Consolidate the comments or place the directive immediately before the function signature.
Current code
// `@ts-expect-error`
// eslint-disable-next-line `@typescript-eslint/no-unused-vars`
async function matchFileSnapshot(data: any, postFix = "") {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/xl-ai/src/api/formats/tests/sharedTestCases.ts` around lines 23 -
24, Move the TypeScript suppression so it directly precedes the function
signature for matchFileSnapshot: remove or reorder the two comments so that the
`@ts-expect-error` is immediately above async function matchFileSnapshot(data:
any, postFix = "") (and keep or merge the eslint-disable-next-line comment
appropriately), ensuring the `@ts-expect-error` applies to the unused postFix
parameter.
…suppression Replace all 5 @ts-ignore comments with @ts-expect-error across the codebase. @ts-expect-error will flag when suppressions become unnecessary, preventing stale type suppressions from accumulating. Nightshift-Task: lint-fix Nightshift-Ref: https://github.com/marcus/nightshift Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
b0badc9 to
957ddf9
Compare
Summary
@ts-ignorecomments with@ts-expect-erroracross the codebase@ts-expect-errorwill flag when suppressions become unnecessary, preventing stale type suppressionsFiles changed
packages/core/src/editor/BlockNoteEditor.tspackages/core/src/schema/inlineContent/types.tspackages/xl-ai/src/api/formats/tests/sharedTestCases.tspackages/xl-ai/src/prosemirror/rebaseTool.tspackages/xl-odt-exporter/src/odt/odtExporter.test.tsTest plan
pnpm run lint)Nightshift-Task: lint-fix
Nightshift-Ref: https://github.com/marcus/nightshift
🤖 Generated with Claude Code
Summary by CodeRabbit