Skip to content

feat: add iterateComments method#758

Merged
JoshuaKGoldberg merged 16 commits into
JoshuaKGoldberg:mainfrom
fisker:iterateComments
Dec 28, 2025
Merged

feat: add iterateComments method#758
JoshuaKGoldberg merged 16 commits into
JoshuaKGoldberg:mainfrom
fisker:iterateComments

Conversation

@fisker

@fisker fisker commented Sep 29, 2025

Copy link
Copy Markdown
Contributor

PR Checklist

Overview

This contains change from #756, if we decide to add them one by one, should merge #756 first.

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review December 27, 2025 04:37

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

LGTM in general - with one note on the missing text.

Again, apologies for taking so long on this. Once I get confirmation on the intent with text I can merge and release. 👍

Comment thread src/comments.ts Outdated
const comments: Comment[] = [];

execute((pos: number, end: number, kind: ts.CommentKind) => {
comments.push({ end, fullText, kind, pos });

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

[Bug] text missing in the output is causing the tests to fail. I think text was meant to be included - is something like this missing?

Suggested change
comments.push({ end, fullText, kind, pos });
comments.push({ end, fullText, kind, pos, text: fullText.slice(pos, end) });
export type Comment = ts.CommentRange & {
	fullText: string;
+	text: string;
};

@JoshuaKGoldberg JoshuaKGoldberg added the status: waiting for author Needs an action taken by the original poster label Dec 27, 2025
@codecov

codecov Bot commented Dec 27, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.46%. Comparing base (f6fda9b) to head (20666e5).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #758      +/-   ##
==========================================
+ Coverage   61.13%   61.46%   +0.32%     
==========================================
  Files          35       35              
  Lines        2923     2948      +25     
  Branches      468      473       +5     
==========================================
+ Hits         1787     1812      +25     
  Misses       1136     1136              
Flag Coverage Δ
4.8.4 60.07% <100.00%> (+0.34%) ⬆️
latest 60.71% <100.00%> (+0.33%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

@fisker

fisker commented Dec 27, 2025

Copy link
Copy Markdown
Contributor Author

I don't remember what I was thinking. But it currently yields

{
	kind: CommentKind;
    pos: number;
    end: number;
	fullText: string;
}

Do you have a preferences that what it should look like?

fullText seems not very useful to me.

@JoshuaKGoldberg

Copy link
Copy Markdown
Owner

Hmm, yeah, I think removing fullText and adding back text is what I'd prefer.

@fisker

fisker commented Dec 28, 2025

Copy link
Copy Markdown
Contributor Author

@JoshuaKGoldberg

Copy link
Copy Markdown
Owner

Is that value not just the same thing as text?

@fisker

fisker commented Dec 28, 2025

Copy link
Copy Markdown
Contributor Author

No,

// foo

{
	text: '// foo',
	value: ' foo'
}

/* foo */

{
	text: '/* foo */',
	value: ' foo '
}

Unless you mean to provide value instead of text.

@JoshuaKGoldberg

Copy link
Copy Markdown
Owner

OH! Gotcha - I think it'd be useful to provide both. At least text is good for the full text, and value is nice as friendly time-saver for users. But if you feel strongly about just providing text, I wouldn't be upset about just providing it for now.

@fisker

fisker commented Dec 28, 2025

Copy link
Copy Markdown
Contributor Author

Let's add value then.

@fisker

fisker commented Dec 28, 2025

Copy link
Copy Markdown
Contributor Author

Is the test failure related? Or should I ignore?

@JoshuaKGoldberg

Copy link
Copy Markdown
Owner

You can ignore them, I just filed #768.

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

💯 lovely, thank you!

By the way, I filed #767 to group together pending changes for a next major in perhaps a couple of months. That includes the #588 -> #711 feature you'd suggested a bit back. If there's anything else you're interested in, I'm on deck to help get it in. 🙂 lmk!

@JoshuaKGoldberg JoshuaKGoldberg merged commit ea4e4c0 into JoshuaKGoldberg:main Dec 28, 2025
18 of 20 checks passed
@JoshuaKGoldberg

Copy link
Copy Markdown
Owner

Published in ts-api-utils@2.3.0 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting for author Needs an action taken by the original poster

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚀 Feature: Replace forEach... methods with Iterables

2 participants