diff --git a/crates/oxc_ast/src/ast_impl/ts.rs b/crates/oxc_ast/src/ast_impl/ts.rs index f7dcf2efba71f9..2a0f8e646e433e 100644 --- a/crates/oxc_ast/src/ast_impl/ts.rs +++ b/crates/oxc_ast/src/ast_impl/ts.rs @@ -126,8 +126,29 @@ impl<'a> TSType<'a> { } impl TSAccessibility { - pub fn is_private(&self) -> bool { - matches!(self, TSAccessibility::Private) + #[inline] + pub fn is_private(self) -> bool { + matches!(self, Self::Private) + } + + pub fn as_str(self) -> &'static str { + match self { + Self::Public => "public", + Self::Private => "private", + Self::Protected => "protected", + } + } +} + +impl From for &'static str { + fn from(accessibility: TSAccessibility) -> Self { + accessibility.as_str() + } +} + +impl fmt::Display for TSAccessibility { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(self.as_str()) } }