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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/ast_impl/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,7 @@ impl<'a> ClassElement<'a> {
matches!(self, Self::StaticBlock(_))
}

/// 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.
Comment on lines -1306 to 1307
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.

pub fn r#static(&self) -> bool {
match self {
Expand Down
Loading