Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(ast): fix comment of ClassElement::r#static #6731

Merged
merged 3 commits into from
Oct 22, 2024

Conversation

KermanX
Copy link
Contributor

@KermanX KermanX commented Oct 21, 2024

The comment says: Returns true if this ClassElement is a static block or has a static modifier.

Copy link

graphite-app bot commented Oct 21, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “0-merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

@github-actions github-actions bot added A-ast Area - AST C-bug Category - Bug labels Oct 21, 2024
Copy link

codspeed-hq bot commented Oct 21, 2024

CodSpeed Performance Report

Merging #6731 will not alter performance

Comparing KermanX:fix/class-element-static (3a4117f) with main (a7dd5aa)

Summary

✅ 30 untouched benchmarks

Dunqing
Dunqing previously approved these changes Oct 21, 2024
Copy link
Member

@Dunqing Dunqing left a comment

Choose a reason for hiding this comment

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

Thanks!

@Dunqing
Copy link
Member

Dunqing commented Oct 21, 2024

Wait, I just realized this comment was added later and it's wrong.

@Dunqing Dunqing requested a review from DonIsaac October 21, 2024 08:51
@DonIsaac
Copy link
Contributor

Yeah it returns true for static properties. Static blocks aren't properties

@KermanX
Copy link
Contributor Author

KermanX commented Oct 22, 2024

I've reverted the code change and updated the comment :)

@KermanX KermanX changed the title fix(ast): ClassElement::r#static should return true for static block chore(ast): fix comment of ClassElement::r#static Oct 22, 2024
@github-actions github-actions bot added the C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior label Oct 22, 2024
@Boshen Boshen changed the title chore(ast): fix comment of ClassElement::r#static docs(ast): fix comment of ClassElement::r#static Oct 22, 2024
@Boshen Boshen merged commit c916505 into oxc-project:main Oct 22, 2024
3 checks passed
@github-actions github-actions bot added the C-docs Category - Documentation. Related to user-facing or internal documentation label Oct 22, 2024
Comment on lines -1306 to 1307
/// Returns `true` if this [`ClassElement`] is a static block or has a
/// Returns `true` if this [`ClassElement`] is a property and has a
/// static modifier.
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry to be a pain, but I don't think this is quite right either, because this suggests it has to be a property, not a method.

I suggest let's clear this up for once and for all!

/// Returns `true` if this [`ClassElement`] has a static modifier.
/// 
/// Note: Class static blocks do not have a "modifier", as there is no non-static equivalent.
/// Therefore, returns `false` for static blocks.
///
/// The following all return `true`:
/// ```ts
/// class {
///   static prop = 1;
///   static method() {}
///   static #private = 2;
///   static #privateMethod() {}
///   static accessor accessorProp = 3;
///   static accessor #privateAccessorProp = 4;
/// }
/// ```

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm too late. Merged while I was writing! Will make a follow-up PR.

Boshen pushed a commit that referenced this pull request Oct 22, 2024
Follow-up after #6731. Make a long comment to remove ambiguity about what this method does for once and for all!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ast Area - AST C-bug Category - Bug C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior C-docs Category - Documentation. Related to user-facing or internal documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants