Skip to content

Fix type error when slicing annotation block content - #650

Merged
joelzwarrington merged 1 commit into
mainfrom
joelw/fix-annotations-type-error
Oct 20, 2026
Merged

joelzwarrington merged 1 commit into
mainfrom
joelw/fix-annotations-type-error

Conversation

@joelzwarrington

Copy link
Copy Markdown
Contributor

Seeing a CI failure from main:
CleanShot 2026-10-19 at 7 44 41 PM

TS2345: Argument of type 'number | null' is not assignable to parameter of type 'number | undefined' in src/tokenizer/plugins/annotations.ts.

The issue is coming from two PRs which merged around the same time. #642 added a call to findTagEnd(text), which returns number | null, and passed the result straight to String.prototype.slice. #639 upgraded markdown-it to 15.0.1, whose type definitions give state.getLines() a return type of string instead of any. Once both were merged, TypeScript started checking that slice call and rejected the possible null.

This PR stores the result of findTagEnd(text) in a variable and returns false from the block rule if it's null, the same way the earlier tagEnd check does. We've already found a tag end in state.src by that point, so this shouldn't change runtime behavior; it just makes the bail-out explicit.

findTagEnd returns number | null, which String.prototype.slice rejects
now that markdown-it 15's types make state.getLines return string.
Bail out explicitly when no tag end is found.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Committed-By-Agent: claude
@joelzwarrington
joelzwarrington requested a review from a team October 20, 2026 01:48
@joelzwarrington
joelzwarrington merged commit c7b2709 into main Oct 20, 2026
5 checks passed
@joelzwarrington
joelzwarrington deleted the joelw/fix-annotations-type-error branch October 20, 2026 02:09
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