Skip to content

fix: bound attr with type#465

Merged
LuLaValva merged 2 commits intomainfrom
attr-value-type
Mar 5, 2026
Merged

fix: bound attr with type#465
LuLaValva merged 2 commits intomainfrom
attr-value-type

Conversation

@LuLaValva
Copy link
Copy Markdown
Member

<return:=foo as Bar> was being transformed into fooas Bar instead of foo as Bar

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 5, 2026

🦋 Changeset detected

Latest commit: a33301f

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

This PR includes changesets to release 4 packages
Name Type
@marko/language-server Patch
@marko/language-tools Patch
@marko/type-check Patch
marko-vscode 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

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 5, 2026

Walkthrough

This pull request adds support for bound values with types. It includes a changeset file documenting patch version bumps for the language-server, language-tools, type-check, and marko-vscode packages. New test fixtures for return-as-type behavior are added to the language-server package. The script extractor in language-tools is modified to add spacing in the value binding output when processing bound ranges.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: bound attr with type' directly addresses the core issue being fixed - spaces being removed in bound attributes with type annotations.
Description check ✅ Passed The description clearly explains the bug fix with a concrete example showing the transformation problem and the correct expected output.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch attr-value-type

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.

🧹 Nitpick comments (1)
packages/language-tools/src/extractors/script/index.ts (1)

971-1002: Consider normalizing value/type spacing across all bound branches.

Line 957 now inserts a separator, but member branches at Line 984 and Line 1001 still concatenate value + types directly. Unifying this logic will reduce branch-specific formatting drift.

♻️ Proposed refactor
@@
-                      this.#extractor
-                        .copy(boundRange.value)
-                        .write(" ")
-                        .copy(boundRange.types)
+                      this.#extractor.copy(boundRange.value);
+                      this.#writeBoundTypes(boundRange.types);
+                      this.#extractor
                         .write(`\n)${SEP_COMMA_NEW_LINE}"`)
@@
-                      this.#extractor
+                      this.#extractor
                         .copy(boundRange.value)
                         .copy({
                           start: boundRange.value.end,
                           end: boundRange.value.end + 1,
                         })
                         .copy(boundRange.member)
                         .copy({
                           start: boundRange.member.end,
                           end: boundRange.member.end + 1,
                         })
-                        .copy(boundRange.types)
+                      this.#writeBoundTypes(boundRange.types);
+                      this.#extractor
                         .write(`\n)${SEP_COMMA_NEW_LINE}"`)
@@
-                      this.#extractor
-                        .copy(memberRange)
-                        .copy(boundRange.types)
+                      this.#extractor.copy(memberRange);
+                      this.#writeBoundTypes(boundRange.types);
+                      this.#extractor
                         .write(`\n)${SEP_COMMA_NEW_LINE}"`)
@@
+  `#writeBoundTypes`(types: Range) {
+    if (types.start < types.end) {
+      this.#extractor.write(" ").copy(types);
+    }
+  }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/language-tools/src/extractors/script/index.ts` around lines 971 -
1002, The computed-member branch adds a separator (SEP_COMMA_NEW_LINE) between
the value and types before writing the trailing key, but the static-member
branch (using memberRange) and the other else branch still concatenate value +
types directly; update the branches that call this.#extractor.copy(memberRange
or boundRange.value).copy(boundRange.types)...write(...) to insert the same
separator/spacing (SEP_COMMA_NEW_LINE) and follow the identical sequence used in
the boundRange.member.computed branch so value/type spacing is normalized across
boundRange.member.computed, the static member branch, and any other bound
branches that write the final key.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/language-tools/src/extractors/script/index.ts`:
- Around line 971-1002: The computed-member branch adds a separator
(SEP_COMMA_NEW_LINE) between the value and types before writing the trailing
key, but the static-member branch (using memberRange) and the other else branch
still concatenate value + types directly; update the branches that call
this.#extractor.copy(memberRange or
boundRange.value).copy(boundRange.types)...write(...) to insert the same
separator/spacing (SEP_COMMA_NEW_LINE) and follow the identical sequence used in
the boundRange.member.computed branch so value/type spacing is normalized across
boundRange.member.computed, the static member branch, and any other bound
branches that write the final key.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 881aecaf-b0db-474d-aacb-e55799593071

📥 Commits

Reviewing files that changed from the base of the PR and between f2372bb and a33301f.

⛔ Files ignored due to path filters (6)
  • packages/language-server/src/__tests__/fixtures/script/return-as-type/__snapshots__/return-as-type.expected/index.html is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/return-as-type/__snapshots__/return-as-type.expected/index.md is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/return-as-type/__snapshots__/return-as-type.expected/index.ts is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/return-as-type/__snapshots__/return-as-type.expected/tags/oneOrTwo.html is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/return-as-type/__snapshots__/return-as-type.expected/tags/oneOrTwo.md is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/return-as-type/__snapshots__/return-as-type.expected/tags/oneOrTwo.ts is excluded by !**/__snapshots__/** and included by **
📒 Files selected for processing (4)
  • .changeset/curly-horses-behave.md
  • packages/language-server/src/__tests__/fixtures/script/return-as-type/index.marko
  • packages/language-server/src/__tests__/fixtures/script/return-as-type/tags/oneOrTwo.marko
  • packages/language-tools/src/extractors/script/index.ts

@LuLaValva LuLaValva merged commit d3aa173 into main Mar 5, 2026
5 checks passed
@LuLaValva LuLaValva deleted the attr-value-type branch March 5, 2026 23:10
@github-actions github-actions bot mentioned this pull request Mar 5, 2026
@github-project-automation github-project-automation bot moved this from Todo to Done in Roadmap Mar 6, 2026
@github-project-automation github-project-automation bot moved this to Todo in Roadmap Mar 6, 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.

2 participants