Skip to content

fix(expression): end type annotation at function body brace#224

Merged
DylanPiercey merged 1 commit into
mainfrom
claude/htmljs-parser-215-ntw9zb
Jun 25, 2026
Merged

fix(expression): end type annotation at function body brace#224
DylanPiercey merged 1 commit into
mainfrom
claude/htmljs-parser-215-ntw9zb

Conversation

@DylanPiercey

Copy link
Copy Markdown
Contributor

Fixes #215.

A statement function (export/static) that declares a return type left the parser in "type" mode for the body, so a > was parsed as a closing generic bracket:

export function a(): b {
  return c > d; // Mismatched group. A ">" character was found when "}" was expected.
}

A { that follows a completed type now ends the annotation and the block is parsed as a value. Object types (x: { a: 1 }), generics, and type/interface/declare bodies are unaffected. Adds a regression fixture.


Generated by Claude Code

A `{` following a completed type now ends the return type annotation so a
`>` in the body is no longer parsed as a closing generic bracket.

Fixes #215
@changeset-bot

changeset-bot Bot commented Jun 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 815055c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
htmljs-parser Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.95%. Comparing base (8d38c8b) to head (815055c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #224   +/-   ##
=======================================
  Coverage   99.95%   99.95%           
=======================================
  Files          34       34           
  Lines        4223     4233   +10     
  Branches      780      782    +2     
=======================================
+ Hits         4221     4231   +10     
  Misses          2        2           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

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: c84978d4-6bf6-43ac-b490-54aefc118d3b

📥 Commits

Reviewing files that changed from the base of the PR and between 8d38c8b and 815055c.

⛔ Files ignored due to path filters (1)
  • src/__tests__/fixtures/ts-statement-function-return-type/__snapshots__/ts-statement-function-return-type.expected.txt is excluded by !**/__snapshots__/** and included by **
📒 Files selected for processing (3)
  • .changeset/statement-fn-return-type-body.md
  • src/__tests__/fixtures/ts-statement-function-return-type/input.marko
  • src/states/EXPRESSION.ts

Walkthrough

EXPRESSION.ts now conditionally clears expression.inType in OPEN_CURLY_BRACE when no operator is found behind the brace. A new Marko fixture adds exported statement-function examples, a generic helper, and a trailing div. A changeset file was added for the parser fix.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the parser fix for ending type annotations at the function body brace.
Description check ✅ Passed The description directly matches the code changes and regression fixture added in this PR.
Linked Issues check ✅ Passed The changes address #215 by exiting type mode when the body starts, so > inside the body parses correctly.
Out of Scope Changes check ✅ Passed All changes appear in scope: parser logic, regression fixture, and related changeset note.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 claude/htmljs-parser-215-ntw9zb

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

@DylanPiercey DylanPiercey merged commit aaeb3fd into main Jun 25, 2026
11 checks passed
@DylanPiercey DylanPiercey deleted the claude/htmljs-parser-215-ntw9zb branch June 25, 2026 23:02
DylanPiercey added a commit to marko-js/tree-sitter that referenced this pull request Jun 26, 2026
Port htmljs-parser's statement-function return type fix to the external
scanner. A `{` following a completed type now ends the type annotation so
a `>` in the function body is no longer parsed as a closing generic
bracket. If the preceding non-whitespace is an operator/continuation the
`{` is treated as part of the type (eg an object return type) and type
mode stays on.

Mirrors marko-js/htmljs-parser#224.
DylanPiercey added a commit to marko-js/tree-sitter that referenced this pull request Jun 26, 2026
Port htmljs-parser's statement-function return type fix to the external
scanner. A `{` following a completed type now ends the type annotation so
a `>` in the function body is no longer parsed as a closing generic
bracket. If the preceding non-whitespace is an operator/continuation the
`{` is treated as part of the type (eg an object return type) and type
mode stays on.

Mirrors marko-js/htmljs-parser#224.
@github-actions github-actions Bot mentioned this pull request Jun 26, 2026
@DylanPiercey DylanPiercey moved this to Done in Roadmap Jun 29, 2026
@DylanPiercey DylanPiercey self-assigned this Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

mismatched group with export/static function with a type param and a >

1 participant