Skip to content

refactor: replace @ts-ignore with @ts-expect-error for stricter type suppression#2581

Merged
nperez0111 merged 2 commits intomainfrom
nightshift/lint-fix
Apr 13, 2026
Merged

refactor: replace @ts-ignore with @ts-expect-error for stricter type suppression#2581
nperez0111 merged 2 commits intomainfrom
nightshift/lint-fix

Conversation

@nperez0111
Copy link
Copy Markdown
Contributor

@nperez0111 nperez0111 commented Mar 21, 2026

Summary

  • Replaced all 5 @ts-ignore comments with @ts-expect-error across the codebase
  • Each suppression includes a descriptive comment explaining why it's needed
  • @ts-expect-error will flag when suppressions become unnecessary, preventing stale type suppressions

Files changed

  • packages/core/src/editor/BlockNoteEditor.ts
  • packages/core/src/schema/inlineContent/types.ts
  • packages/xl-ai/src/api/formats/tests/sharedTestCases.ts
  • packages/xl-ai/src/prosemirror/rebaseTool.ts
  • packages/xl-odt-exporter/src/odt/odtExporter.test.ts

Test plan

  • Lint passes (pnpm run lint)
  • Prettier formatting verified on changed files
  • No snapshot files modified (avoiding test breakage from prior iteration)

Nightshift-Task: lint-fix
Nightshift-Ref: https://github.com/marcus/nightshift

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Strengthened TypeScript checks across the codebase by converting unconditional suppression directives to stricter expectations where appropriate.
    • Tightened test and build-time type validation for editor, schema, AI, and export-related modules to surface potential typing issues earlier.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 21, 2026

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

Project Deployment Actions Updated (UTC)
blocknote Ready Ready Preview Apr 13, 2026 0:04am
blocknote-website Ready Ready Preview Apr 13, 2026 0:04am

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e5529b05-ce22-4d5a-9611-f1e9c2f6111d

📥 Commits

Reviewing files that changed from the base of the PR and between 957ddf9 and 28ac327.

📒 Files selected for processing (5)
  • packages/core/src/editor/BlockNoteEditor.ts
  • packages/core/src/schema/inlineContent/types.ts
  • packages/xl-ai/src/api/formats/tests/sharedTestCases.ts
  • packages/xl-ai/src/prosemirror/rebaseTool.ts
  • packages/xl-odt-exporter/src/odt/odtExporter.test.ts
💤 Files with no reviewable changes (2)
  • packages/core/src/editor/BlockNoteEditor.ts
  • packages/core/src/schema/inlineContent/types.ts
✅ Files skipped from review due to trivial changes (2)
  • packages/xl-ai/src/api/formats/tests/sharedTestCases.ts
  • packages/xl-odt-exporter/src/odt/odtExporter.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/xl-ai/src/prosemirror/rebaseTool.ts

📝 Walkthrough

Walkthrough

TypeScript suppression directives were adjusted across five files: two locations had // @ts-ignore removed, and three locations replaced `// `@ts-ignore with // @ts-expect-error``, altering how the compiler treats those specific lines.

Changes

Cohort / File(s) Summary
Core package — editor & schema
packages/core/src/editor/BlockNoteEditor.ts, packages/core/src/schema/inlineContent/types.ts
Removed // @ts-ignore`` directives preceding a schema assignment and an exported type declaration, restoring normal type-checking for those lines.
XL-AI package — tests & rebase tool
packages/xl-ai/src/api/formats/tests/sharedTestCases.ts, packages/xl-ai/src/prosemirror/rebaseTool.ts
Replaced // @ts-ignore with `// `@ts-expect-error on a test helper and an applySuggestionsTr null-check site, changing suppression to expect an actual type error.
XL-ODT-exporter — tests
packages/xl-odt-exporter/src/odt/odtExporter.test.ts
Replaced // @ts-ignore with `// `@ts-expect-error when polyfilling globalThis.Blob in tests, making the suppression conditional on an actual type error.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I nibbled at ignores in the night,
Swapped and trimmed each comment tight,
Expecting errors where they may be,
Cleaner checks for code and me.
✨ A tiny hop toward type safety.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: replacing @ts-ignore with @ts-expect-error for stricter type suppression.
Description check ✅ Passed The description provides a clear summary, rationale, list of changed files, and test verification, though it omits several template sections like detailed impact analysis and a formal checklist.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch nightshift/lint-fix

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3f642c8 and 5bea0e4.

📒 Files selected for processing (6)
  • docs/components/FadeIn.tsx
  • packages/core/src/editor/BlockNoteEditor.ts
  • packages/core/src/schema/inlineContent/types.ts
  • packages/xl-ai/src/api/formats/tests/sharedTestCases.ts
  • packages/xl-ai/src/prosemirror/rebaseTool.ts
  • packages/xl-odt-exporter/src/odt/odtExporter.test.ts

Comment on lines 23 to 24
// @ts-expect-error
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 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.ts

Repository: TypeCellOS/BlockNote

Length of output: 151


🏁 Script executed:

sed -n '20,35p' packages/xl-ai/src/api/formats/tests/sharedTestCases.ts | cat -n

Repository: 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 -20

Repository: 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.ts

Repository: 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 -n

Repository: 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 -n

Repository: 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 -40

Repository: 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-list

Repository: 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 -40

Repository: 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.

@nperez0111 nperez0111 force-pushed the nightshift/lint-fix branch from b0badc9 to 957ddf9 Compare March 21, 2026 22:03
@nperez0111 nperez0111 changed the title chore: replace @ts-ignore with @ts-expect-error and fix formatting refactor: replace @ts-ignore with @ts-expect-error for stricter type suppression Mar 21, 2026
Nick the Sick and others added 2 commits April 13, 2026 13:40
…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>
@nperez0111 nperez0111 force-pushed the nightshift/lint-fix branch from 957ddf9 to 28ac327 Compare April 13, 2026 11:59
@nperez0111 nperez0111 merged commit c921a7b into main Apr 13, 2026
19 of 21 checks passed
@nperez0111 nperez0111 deleted the nightshift/lint-fix branch April 13, 2026 12:16
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