Skip to content

Commit

Permalink
docs(ast): fix comment for ClassElement::r#static
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Oct 22, 2024
1 parent c916505 commit 2921f72
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions crates/oxc_ast/src/ast_impl/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1344,8 +1344,22 @@ impl<'a> ClassElement<'a> {
matches!(self, Self::StaticBlock(_))
}

/// Returns `true` if this [`ClassElement`] is a property and has a
/// static modifier.
/// 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;
/// }
/// ```
pub fn r#static(&self) -> bool {
match self {
Self::TSIndexSignature(_) | Self::StaticBlock(_) => false,
Expand Down

0 comments on commit 2921f72

Please sign in to comment.