repo stringlengths 6 65 | file_url stringlengths 81 311 | file_path stringlengths 6 227 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:31:58 2026-01-04 20:25:31 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/reference_type.rs | crates/rome_js_formatter/src/ts/types/reference_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsReferenceType, TsReferenceTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsReferenceType;
impl FormatNodeRule<TsReferenceType> for FormatTsReferenceType {
fn fmt_fields(&self, node: &TsReferenceType, f: &mut JsFormatter) -> FormatResult<()> {
let TsReferenceTypeFields {
name,
type_arguments,
} = node.as_fields();
write![f, [name.format(), type_arguments.format()]]
}
fn needs_parentheses(&self, item: &TsReferenceType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsReferenceType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/constructor_type.rs | crates/rome_js_formatter/src/ts/types/constructor_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use crate::ts::types::function_type::function_like_type_needs_parentheses;
use rome_formatter::write;
use rome_js_syntax::TsConstructorTypeFields;
use rome_js_syntax::{JsSyntaxNode, TsConstructorType};
#[derive(Debug, Clone, Default)]
pub struct FormatTsConstructorType;
impl FormatNodeRule<TsConstructorType> for FormatTsConstructorType {
fn fmt_fields(&self, node: &TsConstructorType, f: &mut JsFormatter) -> FormatResult<()> {
let TsConstructorTypeFields {
abstract_token,
new_token,
type_parameters,
parameters,
fat_arrow_token,
return_type,
} = node.as_fields();
if let Some(abstract_token) = abstract_token {
write!(f, [abstract_token.format(), space()])?;
}
write![
f,
[
new_token.format(),
space(),
type_parameters.format(),
parameters.format(),
space(),
fat_arrow_token.format(),
space(),
return_type.format()
]
]
}
fn needs_parentheses(&self, item: &TsConstructorType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsConstructorType {
fn needs_parentheses_with_parent(&self, parent: &JsSyntaxNode) -> bool {
function_like_type_needs_parentheses(self.syntax(), parent)
}
}
#[cfg(test)]
mod tests {
use crate::{assert_needs_parentheses, assert_not_needs_parentheses};
use rome_js_syntax::TsConstructorType;
#[test]
fn needs_parentheses() {
assert_needs_parentheses!("type s = (new () => string)[]", TsConstructorType);
assert_needs_parentheses!("type s = unique (new () => string);", TsConstructorType);
assert_needs_parentheses!(
"type s = [number, ...(new () => string)]",
TsConstructorType
);
assert_needs_parentheses!("type s = [(new () => string)?]", TsConstructorType);
assert_needs_parentheses!("type s = (new () => string)[a]", TsConstructorType);
assert_not_needs_parentheses!("type s = a[new () => string]", TsConstructorType);
assert_needs_parentheses!("type s = (new () => string) & b", TsConstructorType);
assert_needs_parentheses!("type s = a & (new () => string)", TsConstructorType);
// This does require parentheses but the formatter will strip the leading `&`, leaving only the inner type
// thus, no parentheses are required
assert_not_needs_parentheses!("type s = &(new () => string)", TsConstructorType);
assert_needs_parentheses!("type s = (new () => string) | b", TsConstructorType);
assert_needs_parentheses!("type s = a | (new () => string)", TsConstructorType);
assert_not_needs_parentheses!("type s = |(new () => string)", TsConstructorType);
assert_needs_parentheses!(
"type s = (new () => string) extends string ? string : number",
TsConstructorType
);
assert_not_needs_parentheses!(
"type s = A extends string ? (new () => string) : number",
TsConstructorType
);
assert_not_needs_parentheses!(
"type s = A extends string ? string : (new () => string)",
TsConstructorType
)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/number_literal_type.rs | crates/rome_js_formatter/src/ts/types/number_literal_type.rs | use crate::prelude::*;
use rome_formatter::token::number::format_number_token;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsNumberLiteralType, TsNumberLiteralTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsNumberLiteralType;
impl FormatNodeRule<TsNumberLiteralType> for FormatTsNumberLiteralType {
fn fmt_fields(&self, node: &TsNumberLiteralType, f: &mut JsFormatter) -> FormatResult<()> {
let TsNumberLiteralTypeFields {
minus_token,
literal_token,
} = node.as_fields();
write![
f,
[minus_token.format(), format_number_token(&literal_token?)]
]
}
fn needs_parentheses(&self, item: &TsNumberLiteralType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsNumberLiteralType {
fn needs_parentheses_with_parent(&self, _: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/string_type.rs | crates/rome_js_formatter/src/ts/types/string_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsStringType, TsStringTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsStringType;
impl FormatNodeRule<TsStringType> for FormatTsStringType {
fn fmt_fields(&self, node: &TsStringType, f: &mut JsFormatter) -> FormatResult<()> {
let TsStringTypeFields { string_token } = node.as_fields();
write![f, [string_token.format()]]
}
fn needs_parentheses(&self, item: &TsStringType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsStringType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/symbol_type.rs | crates/rome_js_formatter/src/ts/types/symbol_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsSymbolType, TsSymbolTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsSymbolType;
impl FormatNodeRule<TsSymbolType> for FormatTsSymbolType {
fn fmt_fields(&self, node: &TsSymbolType, f: &mut JsFormatter) -> FormatResult<()> {
let TsSymbolTypeFields { symbol_token } = node.as_fields();
write![f, [symbol_token.format()]]
}
fn needs_parentheses(&self, item: &TsSymbolType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsSymbolType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/any_type.rs | crates/rome_js_formatter/src/ts/types/any_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsAnyType, TsAnyTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsAnyType;
impl FormatNodeRule<TsAnyType> for FormatTsAnyType {
fn fmt_fields(&self, node: &TsAnyType, f: &mut JsFormatter) -> FormatResult<()> {
let TsAnyTypeFields { any_token } = node.as_fields();
write![f, [any_token.format()]]
}
fn needs_parentheses(&self, item: &TsAnyType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsAnyType {
#[inline]
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/number_type.rs | crates/rome_js_formatter/src/ts/types/number_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsNumberType, TsNumberTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsNumberType;
impl FormatNodeRule<TsNumberType> for FormatTsNumberType {
fn fmt_fields(&self, node: &TsNumberType, f: &mut JsFormatter) -> FormatResult<()> {
let TsNumberTypeFields { number_token } = node.as_fields();
write![f, [number_token.format()]]
}
fn needs_parentheses(&self, item: &TsNumberType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsNumberType {
fn needs_parentheses_with_parent(&self, _: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/infer_type.rs | crates/rome_js_formatter/src/ts/types/infer_type.rs | use crate::prelude::*;
use crate::parentheses::{operator_type_or_higher_needs_parens, NeedsParentheses};
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxKind, JsSyntaxNode, TsInferType, TsInferTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsInferType;
impl FormatNodeRule<TsInferType> for FormatTsInferType {
fn fmt_fields(&self, node: &TsInferType, f: &mut JsFormatter) -> FormatResult<()> {
let TsInferTypeFields {
infer_token,
name,
constraint,
} = node.as_fields();
write!(f, [infer_token.format(), space(), name.format()])?;
if let Some(constraint) = constraint {
write!(f, [space(), constraint.format()])?;
}
Ok(())
}
fn needs_parentheses(&self, item: &TsInferType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsInferType {
fn needs_parentheses_with_parent(&self, parent: &JsSyntaxNode) -> bool {
if parent.kind() == JsSyntaxKind::TS_REST_TUPLE_TYPE_ELEMENT {
false
} else {
operator_type_or_higher_needs_parens(self.syntax(), parent)
}
}
}
#[cfg(test)]
mod tests {
use crate::{assert_needs_parentheses, assert_not_needs_parentheses};
use rome_js_syntax::TsInferType;
#[test]
fn needs_parentheses() {
assert_needs_parentheses!("let s: (infer string)[] = symbol();", TsInferType);
assert_needs_parentheses!("let s: unique (infer string);", TsInferType);
assert_not_needs_parentheses!("let s: [number, ...infer string]", TsInferType);
assert_needs_parentheses!("let s: [(infer string)?]", TsInferType);
assert_needs_parentheses!("let s: (infer string)[a]", TsInferType);
assert_not_needs_parentheses!("let s: a[(infer string)]", TsInferType);
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/undefined_type.rs | crates/rome_js_formatter/src/ts/types/undefined_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsUndefinedType, TsUndefinedTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsUndefinedType;
impl FormatNodeRule<TsUndefinedType> for FormatTsUndefinedType {
fn fmt_fields(&self, node: &TsUndefinedType, f: &mut JsFormatter) -> FormatResult<()> {
let TsUndefinedTypeFields { undefined_token } = node.as_fields();
write![f, [undefined_token.format()]]
}
fn needs_parentheses(&self, item: &TsUndefinedType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsUndefinedType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/mapped_type.rs | crates/rome_js_formatter/src/ts/types/mapped_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use crate::utils::FormatOptionalSemicolon;
use rome_formatter::trivia::FormatLeadingComments;
use rome_formatter::{format_args, write};
use rome_js_syntax::{JsSyntaxNode, TsMappedType, TsMappedTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsMappedType;
impl FormatNodeRule<TsMappedType> for FormatTsMappedType {
fn fmt_fields(&self, node: &TsMappedType, f: &mut JsFormatter) -> FormatResult<()> {
let TsMappedTypeFields {
l_curly_token,
readonly_modifier,
l_brack_token,
property_name,
in_token,
keys_type,
as_clause,
r_brack_token,
optional_modifier,
mapped_type,
semicolon_token,
r_curly_token,
} = node.as_fields();
let property_name = property_name?;
// Check if the user introduced a new line inside the node.
let should_expand = node
.syntax()
.tokens()
// Skip the first token to avoid formatter instability. See #4165.
// This also makes sense since leading trivia of the first token
// are not part of the interior of the node.
.skip(1)
.flat_map(|token| {
token
.leading_trivia()
.pieces()
.chain(token.trailing_trivia().pieces())
})
.any(|piece| piece.is_newline());
let comments = f.comments().clone();
let dangling_comments = comments.dangling_comments(node.syntax());
let type_annotation_has_leading_comment =
mapped_type.as_ref().map_or(false, |annotation| {
comments.has_leading_comments(annotation.syntax())
});
let format_inner = format_with(|f| {
if let Some(readonly_modifier) = &readonly_modifier {
write!(f, [readonly_modifier.format(), space()])?;
}
write!(
f,
[
FormatLeadingComments::Comments(dangling_comments),
group(&format_args![
l_brack_token.format(),
property_name.format(),
space(),
in_token.format(),
soft_line_indent_or_space(&format_args![
keys_type.format(),
as_clause.as_ref().map(|_| space()),
as_clause.format(),
]),
r_brack_token.format(),
]),
optional_modifier.format(),
type_annotation_has_leading_comment.then_some(space()),
mapped_type.format(),
if_group_breaks(&FormatOptionalSemicolon::new(semicolon_token.as_ref()))
]
)
});
write!(
f,
[
&l_curly_token.format(),
group(&soft_space_or_block_indent(&format_inner)).should_expand(should_expand),
r_curly_token.format(),
]
)
}
fn needs_parentheses(&self, item: &TsMappedType) -> bool {
item.needs_parentheses()
}
fn fmt_dangling_comments(&self, _: &TsMappedType, _: &mut JsFormatter) -> FormatResult<()> {
// Handled inside of `fmt_fields`
Ok(())
}
}
impl NeedsParentheses for TsMappedType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/function_type.rs | crates/rome_js_formatter/src/ts/types/function_type.rs | use crate::prelude::*;
use crate::js::declarations::function_declaration::should_group_function_parameters;
use crate::parentheses::{
is_check_type, is_in_many_type_union_or_intersection_list,
is_includes_inferred_return_types_with_extends_constraints,
operator_type_or_higher_needs_parens, NeedsParentheses,
};
use rome_formatter::write;
use rome_js_syntax::TsFunctionTypeFields;
use rome_js_syntax::{JsSyntaxKind, JsSyntaxNode, TsFunctionType};
#[derive(Debug, Clone, Default)]
pub struct FormatTsFunctionType;
impl FormatNodeRule<TsFunctionType> for FormatTsFunctionType {
fn fmt_fields(&self, node: &TsFunctionType, f: &mut JsFormatter) -> FormatResult<()> {
let TsFunctionTypeFields {
parameters,
fat_arrow_token,
type_parameters,
return_type,
} = node.as_fields();
let format_inner = format_with(|f| {
write![f, [type_parameters.format()]]?;
let mut format_return_type = return_type.format().memoized();
let should_group_parameters = should_group_function_parameters(
type_parameters.as_ref(),
parameters.as_ref()?.items().len(),
Some(return_type.clone()),
&mut format_return_type,
f,
)?;
if should_group_parameters {
write!(f, [group(¶meters.format())])?;
} else {
write!(f, [parameters.format()])?;
}
write![
f,
[
space(),
fat_arrow_token.format(),
space(),
format_return_type
]
]
});
write!(f, [group(&format_inner)])
}
fn needs_parentheses(&self, item: &TsFunctionType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsFunctionType {
fn needs_parentheses_with_parent(&self, parent: &JsSyntaxNode) -> bool {
function_like_type_needs_parentheses(self.syntax(), parent)
}
}
pub(super) fn function_like_type_needs_parentheses(
node: &JsSyntaxNode,
parent: &JsSyntaxNode,
) -> bool {
match parent.kind() {
JsSyntaxKind::TS_RETURN_TYPE_ANNOTATION => {
let grand_parent = parent.parent();
grand_parent.map_or(false, |grand_parent| {
grand_parent.kind() == JsSyntaxKind::JS_ARROW_FUNCTION_EXPRESSION
})
}
_ => {
is_check_type(node, parent)
|| is_includes_inferred_return_types_with_extends_constraints(node, parent)
|| operator_type_or_higher_needs_parens(node, parent)
|| is_in_many_type_union_or_intersection_list(node, parent)
}
}
}
#[cfg(test)]
mod tests {
use crate::{assert_needs_parentheses, assert_not_needs_parentheses};
use rome_js_syntax::TsFunctionType;
#[test]
fn needs_parentheses() {
assert_needs_parentheses!("type s = (() => string)[]", TsFunctionType);
assert_needs_parentheses!("type s = unique (() => string);", TsFunctionType);
assert_needs_parentheses!("type s = [number, ...(() => string)]", TsFunctionType);
assert_needs_parentheses!("type s = [(() => string)?]", TsFunctionType);
assert_needs_parentheses!("type s = (() => string)[a]", TsFunctionType);
assert_not_needs_parentheses!("type s = a[() => string]", TsFunctionType);
assert_needs_parentheses!("type s = (() => string) & b", TsFunctionType);
assert_needs_parentheses!("type s = a & (() => string)", TsFunctionType);
// This does require parentheses but the formatter will strip the leading `&`, leaving only the inner type
// thus, no parentheses are required
assert_not_needs_parentheses!("type s = &(() => string)", TsFunctionType);
assert_needs_parentheses!("type s = (() => string) | b", TsFunctionType);
assert_needs_parentheses!("type s = a | (() => string)", TsFunctionType);
assert_not_needs_parentheses!("type s = |(() => string)", TsFunctionType);
assert_needs_parentheses!(
"type s = (() => string) extends string ? string : number",
TsFunctionType
);
assert_not_needs_parentheses!(
"type s = A extends string ? (() => string) : number",
TsFunctionType
);
assert_not_needs_parentheses!(
"type s = A extends string ? string : (() => string)",
TsFunctionType
)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/void_type.rs | crates/rome_js_formatter/src/ts/types/void_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsVoidType, TsVoidTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsVoidType;
impl FormatNodeRule<TsVoidType> for FormatTsVoidType {
fn fmt_fields(&self, node: &TsVoidType, f: &mut JsFormatter) -> FormatResult<()> {
let TsVoidTypeFields { void_token } = node.as_fields();
write![f, [void_token.format()]]
}
fn needs_parentheses(&self, item: &TsVoidType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsVoidType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/indexed_access_type.rs | crates/rome_js_formatter/src/ts/types/indexed_access_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::TsIndexedAccessTypeFields;
use rome_js_syntax::{JsSyntaxNode, TsIndexedAccessType};
#[derive(Debug, Clone, Default)]
pub struct FormatTsIndexedAccessType;
impl FormatNodeRule<TsIndexedAccessType> for FormatTsIndexedAccessType {
fn fmt_fields(&self, node: &TsIndexedAccessType, f: &mut JsFormatter) -> FormatResult<()> {
let TsIndexedAccessTypeFields {
object_type,
l_brack_token,
index_type,
r_brack_token,
} = node.as_fields();
write![
f,
[
object_type.format(),
l_brack_token.format(),
index_type.format(),
r_brack_token.format()
]
]
}
fn needs_parentheses(&self, item: &TsIndexedAccessType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsIndexedAccessType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/boolean_literal_type.rs | crates/rome_js_formatter/src/ts/types/boolean_literal_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsBooleanLiteralType, TsBooleanLiteralTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsBooleanLiteralType;
impl FormatNodeRule<TsBooleanLiteralType> for FormatTsBooleanLiteralType {
fn fmt_fields(&self, node: &TsBooleanLiteralType, f: &mut JsFormatter) -> FormatResult<()> {
let TsBooleanLiteralTypeFields { literal } = node.as_fields();
write![f, [literal.format()]]
}
fn needs_parentheses(&self, item: &TsBooleanLiteralType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsBooleanLiteralType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/bigint_literal_type.rs | crates/rome_js_formatter/src/ts/types/bigint_literal_type.rs | use std::borrow::Cow;
use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::token::string::ToAsciiLowercaseCow;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsBigintLiteralType, TsBigintLiteralTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsBigintLiteralType;
impl FormatNodeRule<TsBigintLiteralType> for FormatTsBigintLiteralType {
fn fmt_fields(&self, node: &TsBigintLiteralType, f: &mut JsFormatter) -> FormatResult<()> {
let TsBigintLiteralTypeFields {
minus_token,
literal_token,
} = node.as_fields();
write![f, [minus_token.format()]]?;
let literal_token = literal_token?;
let original = literal_token.text_trimmed();
match original.to_ascii_lowercase_cow() {
Cow::Borrowed(_) => write![f, [literal_token.format()]],
Cow::Owned(lowercase) => {
write!(
f,
[format_replaced(
&literal_token,
&dynamic_text(&lowercase, literal_token.text_trimmed_range().start())
)]
)
}
}
}
fn needs_parentheses(&self, item: &TsBigintLiteralType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsBigintLiteralType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/this_type.rs | crates/rome_js_formatter/src/ts/types/this_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsThisType, TsThisTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsThisType;
impl FormatNodeRule<TsThisType> for FormatTsThisType {
fn fmt_fields(&self, node: &TsThisType, f: &mut JsFormatter) -> FormatResult<()> {
let TsThisTypeFields { this_token } = node.as_fields();
write![f, [this_token.format()]]
}
fn needs_parentheses(&self, item: &TsThisType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsThisType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/mod.rs | crates/rome_js_formatter/src/ts/types/mod.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
pub(crate) mod any_type;
pub(crate) mod array_type;
pub(crate) mod asserts_return_type;
pub(crate) mod bigint_literal_type;
pub(crate) mod bigint_type;
pub(crate) mod boolean_literal_type;
pub(crate) mod boolean_type;
pub(crate) mod conditional_type;
pub(crate) mod constructor_type;
pub(crate) mod function_type;
pub(crate) mod indexed_access_type;
pub(crate) mod infer_type;
pub(crate) mod intersection_type;
pub(crate) mod mapped_type;
pub(crate) mod never_type;
pub(crate) mod non_primitive_type;
pub(crate) mod null_literal_type;
pub(crate) mod number_literal_type;
pub(crate) mod number_type;
pub(crate) mod object_type;
pub(crate) mod parenthesized_type;
pub(crate) mod predicate_return_type;
pub(crate) mod reference_type;
pub(crate) mod string_literal_type;
pub(crate) mod string_type;
pub(crate) mod symbol_type;
pub(crate) mod template_literal_type;
pub(crate) mod this_type;
pub(crate) mod tuple_type;
pub(crate) mod type_operator_type;
pub(crate) mod typeof_type;
pub(crate) mod undefined_type;
pub(crate) mod union_type;
pub(crate) mod unknown_type;
pub(crate) mod void_type;
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/conditional_type.rs | crates/rome_js_formatter/src/ts/types/conditional_type.rs | use crate::prelude::*;
use crate::utils::AnyJsConditional;
use crate::parentheses::{
is_check_type, is_in_many_type_union_or_intersection_list,
operator_type_or_higher_needs_parens, NeedsParentheses,
};
use rome_js_syntax::{JsSyntaxKind, JsSyntaxNode, TsConditionalType};
use rome_rowan::AstNode;
#[derive(Debug, Clone, Default)]
pub struct FormatTsConditionalType;
impl FormatNodeRule<TsConditionalType> for FormatTsConditionalType {
fn fmt_fields(
&self,
node: &TsConditionalType,
formatter: &mut JsFormatter,
) -> FormatResult<()> {
AnyJsConditional::from(node.clone()).format().fmt(formatter)
}
fn needs_parentheses(&self, item: &TsConditionalType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsConditionalType {
fn needs_parentheses_with_parent(&self, parent: &JsSyntaxNode) -> bool {
match parent.kind() {
JsSyntaxKind::TS_CONDITIONAL_TYPE => {
let conditional = TsConditionalType::unwrap_cast(parent.clone());
let is_extends_type = conditional
.extends_type()
.map(AstNode::into_syntax)
.as_ref()
== Ok(self.syntax());
is_check_type(self.syntax(), parent) || is_extends_type
}
_ => {
is_in_many_type_union_or_intersection_list(self.syntax(), parent)
|| operator_type_or_higher_needs_parens(self.syntax(), parent)
}
}
}
}
#[cfg(test)]
mod tests {
use crate::{assert_needs_parentheses, assert_not_needs_parentheses};
use rome_js_syntax::TsConditionalType;
#[test]
fn needs_parentheses() {
assert_needs_parentheses!("type s = (A extends B ? C : D)[]", TsConditionalType);
assert_needs_parentheses!("type s = unique (A extends B ? C : D);", TsConditionalType);
assert_needs_parentheses!(
"type s = [number, ...(A extends B ? C : D)]",
TsConditionalType
);
assert_needs_parentheses!("type s = [(A extends B ? C : D)?]", TsConditionalType);
assert_needs_parentheses!("type s = (A extends B ? C : D)[a]", TsConditionalType);
assert_not_needs_parentheses!("type s = a[A extends B ? C : D]", TsConditionalType);
assert_needs_parentheses!("type s = (A extends B ? C : D) & b", TsConditionalType);
assert_needs_parentheses!("type s = a & (A extends B ? C : D)", TsConditionalType);
// This does require parentheses but the formatter will strip the leading `&`, leaving only the inner type
// thus, no parentheses are required
assert_not_needs_parentheses!("type s = &(A extends B ? C : D)", TsConditionalType);
assert_needs_parentheses!("type s = (A extends B ? C : D) | b", TsConditionalType);
assert_needs_parentheses!("type s = a | (A extends B ? C : D)", TsConditionalType);
assert_not_needs_parentheses!("type s = |(A extends B ? C : D)", TsConditionalType);
assert_needs_parentheses!(
"type s = (A extends B ? C : D) extends E ? F : G",
TsConditionalType[1]
);
assert_not_needs_parentheses!(
"type s = (A extends B ? C : D) extends E ? F : G",
TsConditionalType[0]
);
assert_needs_parentheses!(
"type s = A extends (B extends C ? D : E) ? F : G",
TsConditionalType[1]
);
assert_not_needs_parentheses!(
"type s = A extends (B extends C ? D : E) ? F : G",
TsConditionalType[0]
);
assert_not_needs_parentheses!(
"type s = A extends B ? (C extends D ? E : F) : G",
TsConditionalType[0]
);
assert_not_needs_parentheses!(
"type s = A extends B ? (C extends D ? E : F) : G",
TsConditionalType[1]
);
assert_not_needs_parentheses!(
"type s = A extends B ? C : (D extends E ? F : G)",
TsConditionalType[0]
);
assert_not_needs_parentheses!(
"type s = A extends B ? C : (D extends E ? F : G)",
TsConditionalType[1]
);
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/parenthesized_type.rs | crates/rome_js_formatter/src/ts/types/parenthesized_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::TsParenthesizedTypeFields;
use rome_js_syntax::{JsSyntaxNode, TsParenthesizedType};
#[derive(Debug, Clone, Default)]
pub struct FormatTsParenthesizedType;
impl FormatNodeRule<TsParenthesizedType> for FormatTsParenthesizedType {
fn fmt_fields(&self, node: &TsParenthesizedType, f: &mut JsFormatter) -> FormatResult<()> {
let TsParenthesizedTypeFields {
l_paren_token,
ty,
r_paren_token,
} = node.as_fields();
write!(
f,
[l_paren_token.format(), &ty.format(), r_paren_token.format()]
)
}
fn needs_parentheses(&self, item: &TsParenthesizedType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsParenthesizedType {
#[inline]
fn needs_parentheses(&self) -> bool {
false
}
#[inline]
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/boolean_type.rs | crates/rome_js_formatter/src/ts/types/boolean_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsBooleanType, TsBooleanTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsBooleanType;
impl FormatNodeRule<TsBooleanType> for FormatTsBooleanType {
fn fmt_fields(&self, node: &TsBooleanType, f: &mut JsFormatter) -> FormatResult<()> {
let TsBooleanTypeFields { boolean_token } = node.as_fields();
write![f, [boolean_token.format()]]
}
fn needs_parentheses(&self, item: &TsBooleanType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsBooleanType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/predicate_return_type.rs | crates/rome_js_formatter/src/ts/types/predicate_return_type.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsPredicateReturnType;
use rome_js_syntax::TsPredicateReturnTypeFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsPredicateReturnType;
impl FormatNodeRule<TsPredicateReturnType> for FormatTsPredicateReturnType {
fn fmt_fields(&self, node: &TsPredicateReturnType, f: &mut JsFormatter) -> FormatResult<()> {
let TsPredicateReturnTypeFields {
parameter_name,
is_token,
ty,
} = node.as_fields();
write![
f,
[
parameter_name.format(),
space(),
is_token.format(),
space(),
ty.format()
]
]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/object_type.rs | crates/rome_js_formatter/src/ts/types/object_type.rs | use crate::parentheses::NeedsParentheses;
use crate::prelude::*;
use crate::utils::JsObjectLike;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsObjectType};
#[derive(Debug, Clone, Default)]
pub struct FormatTsObjectType;
impl FormatNodeRule<TsObjectType> for FormatTsObjectType {
fn fmt_fields(&self, node: &TsObjectType, f: &mut JsFormatter) -> FormatResult<()> {
write!(f, [JsObjectLike::from(node.clone())])
}
fn needs_parentheses(&self, item: &TsObjectType) -> bool {
item.needs_parentheses()
}
fn fmt_dangling_comments(&self, _: &TsObjectType, _: &mut JsFormatter) -> FormatResult<()> {
// Formatted inside of `JsObjectLike`
Ok(())
}
}
impl NeedsParentheses for TsObjectType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/array_type.rs | crates/rome_js_formatter/src/ts/types/array_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsArrayType, TsArrayTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsArrayType;
impl FormatNodeRule<TsArrayType> for FormatTsArrayType {
fn fmt_fields(&self, node: &TsArrayType, f: &mut JsFormatter) -> FormatResult<()> {
let TsArrayTypeFields {
l_brack_token,
element_type,
r_brack_token,
} = node.as_fields();
write![
f,
[
element_type.format(),
l_brack_token.format(),
r_brack_token.format(),
]
]
}
fn needs_parentheses(&self, item: &TsArrayType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsArrayType {
#[inline]
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/non_primitive_type.rs | crates/rome_js_formatter/src/ts/types/non_primitive_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsNonPrimitiveType, TsNonPrimitiveTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsNonPrimitiveType;
impl FormatNodeRule<TsNonPrimitiveType> for FormatTsNonPrimitiveType {
fn fmt_fields(&self, node: &TsNonPrimitiveType, f: &mut JsFormatter) -> FormatResult<()> {
let TsNonPrimitiveTypeFields { object_token } = node.as_fields();
write![f, [object_token.format()]]
}
fn needs_parentheses(&self, item: &TsNonPrimitiveType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsNonPrimitiveType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/unknown_type.rs | crates/rome_js_formatter/src/ts/types/unknown_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsUnknownType, TsUnknownTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsUnknownType;
impl FormatNodeRule<TsUnknownType> for FormatTsUnknownType {
fn fmt_fields(&self, node: &TsUnknownType, f: &mut JsFormatter) -> FormatResult<()> {
let TsUnknownTypeFields { unknown_token } = node.as_fields();
write![f, [unknown_token.format()]]
}
fn needs_parentheses(&self, item: &TsUnknownType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsUnknownType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/never_type.rs | crates/rome_js_formatter/src/ts/types/never_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsNeverType, TsNeverTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsNeverType;
impl FormatNodeRule<TsNeverType> for FormatTsNeverType {
fn fmt_fields(&self, node: &TsNeverType, f: &mut JsFormatter) -> FormatResult<()> {
let TsNeverTypeFields { never_token } = node.as_fields();
write![f, [never_token.format()]]
}
fn needs_parentheses(&self, item: &TsNeverType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsNeverType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/types/bigint_type.rs | crates/rome_js_formatter/src/ts/types/bigint_type.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxNode, TsBigintType, TsBigintTypeFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsBigintType;
impl FormatNodeRule<TsBigintType> for FormatTsBigintType {
fn fmt_fields(&self, node: &TsBigintType, f: &mut JsFormatter) -> FormatResult<()> {
let TsBigintTypeFields { bigint_token } = node.as_fields();
write![f, [bigint_token.format()]]
}
fn needs_parentheses(&self, item: &TsBigintType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsBigintType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/bindings/type_parameter.rs | crates/rome_js_formatter/src/ts/bindings/type_parameter.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::{TsTypeParameter, TsTypeParameterFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsTypeParameter;
impl FormatNodeRule<TsTypeParameter> for FormatTsTypeParameter {
fn fmt_fields(&self, node: &TsTypeParameter, f: &mut JsFormatter) -> FormatResult<()> {
let TsTypeParameterFields {
name,
constraint,
default,
modifiers,
} = node.as_fields();
if !modifiers.is_empty() {
write!(f, [modifiers.format(), space()])?;
}
write!(f, [name.format()])?;
if let Some(constraint) = constraint {
write!(f, [space(), constraint.format()])?;
}
if let Some(default) = default {
write!(f, [space(), default.format()])?;
}
Ok(())
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/bindings/property_parameter.rs | crates/rome_js_formatter/src/ts/bindings/property_parameter.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::{TsPropertyParameter, TsPropertyParameterFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsPropertyParameter;
impl FormatNodeRule<TsPropertyParameter> for FormatTsPropertyParameter {
fn fmt_fields(&self, node: &TsPropertyParameter, f: &mut JsFormatter) -> FormatResult<()> {
let TsPropertyParameterFields {
decorators,
modifiers,
formal_parameter,
} = node.as_fields();
let content = format_with(|f| {
write![
f,
[
decorators.format(),
modifiers.format(),
space(),
formal_parameter.format()
]
]
});
if decorators.is_empty() {
write![f, [content]]
} else {
write![f, [group(&content)]]
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/bindings/index_signature_parameter.rs | crates/rome_js_formatter/src/ts/bindings/index_signature_parameter.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::{TsIndexSignatureParameter, TsIndexSignatureParameterFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsIndexSignatureParameter;
impl FormatNodeRule<TsIndexSignatureParameter> for FormatTsIndexSignatureParameter {
fn fmt_fields(
&self,
node: &TsIndexSignatureParameter,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsIndexSignatureParameterFields {
binding,
type_annotation,
} = node.as_fields();
let binding = binding.format();
let type_annotation = type_annotation.format();
write![f, [binding, type_annotation]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/bindings/this_parameter.rs | crates/rome_js_formatter/src/ts/bindings/this_parameter.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::{TsThisParameter, TsThisParameterFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsThisParameter;
impl FormatNodeRule<TsThisParameter> for FormatTsThisParameter {
fn fmt_fields(&self, node: &TsThisParameter, f: &mut JsFormatter) -> FormatResult<()> {
let TsThisParameterFields {
this_token,
type_annotation,
} = node.as_fields();
write![f, [this_token.format(), type_annotation.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/bindings/type_parameters.rs | crates/rome_js_formatter/src/ts/bindings/type_parameters.rs | use crate::prelude::*;
use rome_formatter::FormatError::SyntaxError;
use rome_formatter::{format_args, write, FormatRuleWithOptions, GroupId};
use rome_js_syntax::{TsTypeParameters, TsTypeParametersFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsTypeParameters {
group_id: Option<GroupId>,
}
impl FormatRuleWithOptions<TsTypeParameters> for FormatTsTypeParameters {
type Options = Option<GroupId>;
fn with_options(mut self, options: Self::Options) -> Self {
self.group_id = options;
self
}
}
impl FormatNodeRule<TsTypeParameters> for FormatTsTypeParameters {
fn fmt_fields(&self, node: &TsTypeParameters, f: &mut JsFormatter) -> FormatResult<()> {
let TsTypeParametersFields {
items,
r_angle_token,
l_angle_token,
} = node.as_fields();
if items.is_empty() {
return Err(SyntaxError);
}
write!(
f,
[group(&format_args![
l_angle_token.format(),
soft_block_indent(&items.format()),
r_angle_token.format()
])
.with_group_id(self.group_id)]
)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/bindings/mod.rs | crates/rome_js_formatter/src/ts/bindings/mod.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
pub(crate) mod identifier_binding;
pub(crate) mod index_signature_parameter;
pub(crate) mod property_parameter;
pub(crate) mod this_parameter;
pub(crate) mod type_parameter;
pub(crate) mod type_parameters;
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/bindings/identifier_binding.rs | crates/rome_js_formatter/src/ts/bindings/identifier_binding.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::{TsIdentifierBinding, TsIdentifierBindingFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsIdentifierBinding;
impl FormatNodeRule<TsIdentifierBinding> for FormatTsIdentifierBinding {
fn fmt_fields(&self, node: &TsIdentifierBinding, f: &mut JsFormatter) -> FormatResult<()> {
let TsIdentifierBindingFields { name_token } = node.as_fields();
write![f, [name_token.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/type_parameter_name.rs | crates/rome_js_formatter/src/ts/auxiliary/type_parameter_name.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::{TsTypeParameterName, TsTypeParameterNameFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsTypeParameterName;
impl FormatNodeRule<TsTypeParameterName> for FormatTsTypeParameterName {
fn fmt_fields(&self, node: &TsTypeParameterName, f: &mut JsFormatter) -> FormatResult<()> {
let TsTypeParameterNameFields { ident_token } = node.as_fields();
write![f, [ident_token.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/qualified_module_name.rs | crates/rome_js_formatter/src/ts/auxiliary/qualified_module_name.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsQualifiedModuleName;
use rome_js_syntax::TsQualifiedModuleNameFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsQualifiedModuleName;
impl FormatNodeRule<TsQualifiedModuleName> for FormatTsQualifiedModuleName {
fn fmt_fields(&self, node: &TsQualifiedModuleName, f: &mut JsFormatter) -> FormatResult<()> {
let TsQualifiedModuleNameFields {
left,
dot_token,
right,
} = node.as_fields();
write![f, [left.format(), dot_token.format(), right.format(),]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/mapped_type_optional_modifier_clause.rs | crates/rome_js_formatter/src/ts/auxiliary/mapped_type_optional_modifier_clause.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsMappedTypeOptionalModifierClause;
use rome_js_syntax::TsMappedTypeOptionalModifierClauseFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsMappedTypeOptionalModifierClause;
impl FormatNodeRule<TsMappedTypeOptionalModifierClause>
for FormatTsMappedTypeOptionalModifierClause
{
fn fmt_fields(
&self,
node: &TsMappedTypeOptionalModifierClause,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsMappedTypeOptionalModifierClauseFields {
operator_token,
question_mark_token,
} = node.as_fields();
write![f, [operator_token.format(), question_mark_token.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/optional_property_annotation.rs | crates/rome_js_formatter/src/ts/auxiliary/optional_property_annotation.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsOptionalPropertyAnnotation;
use rome_js_syntax::TsOptionalPropertyAnnotationFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsOptionalPropertyAnnotation;
impl FormatNodeRule<TsOptionalPropertyAnnotation> for FormatTsOptionalPropertyAnnotation {
fn fmt_fields(
&self,
node: &TsOptionalPropertyAnnotation,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsOptionalPropertyAnnotationFields {
question_mark_token,
type_annotation,
} = node.as_fields();
write![f, [question_mark_token.format(), type_annotation.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/override_modifier.rs | crates/rome_js_formatter/src/ts/auxiliary/override_modifier.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsOverrideModifier;
use rome_js_syntax::TsOverrideModifierFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsOverrideModifier;
impl FormatNodeRule<TsOverrideModifier> for FormatTsOverrideModifier {
fn fmt_fields(&self, node: &TsOverrideModifier, f: &mut JsFormatter) -> FormatResult<()> {
let TsOverrideModifierFields { modifier_token } = node.as_fields();
write![f, [modifier_token.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/index_signature_type_member.rs | crates/rome_js_formatter/src/ts/auxiliary/index_signature_type_member.rs | use crate::prelude::*;
use crate::utils::FormatTypeMemberSeparator;
use rome_formatter::write;
use rome_js_syntax::{TsIndexSignatureTypeMember, TsIndexSignatureTypeMemberFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsIndexSignatureTypeMember;
impl FormatNodeRule<TsIndexSignatureTypeMember> for FormatTsIndexSignatureTypeMember {
fn fmt_fields(
&self,
node: &TsIndexSignatureTypeMember,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsIndexSignatureTypeMemberFields {
readonly_token,
l_brack_token,
parameter,
r_brack_token,
type_annotation,
separator_token,
} = node.as_fields();
if let Some(readonly_token) = readonly_token {
write!(f, [readonly_token.format(), space()])?;
}
write![
f,
[
l_brack_token.format(),
parameter.format(),
r_brack_token.format(),
type_annotation.format(),
FormatTypeMemberSeparator::new(separator_token.as_ref()),
]
]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/const_modifier.rs | crates/rome_js_formatter/src/ts/auxiliary/const_modifier.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::{TsConstModifier, TsConstModifierFields};
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatTsConstModifier;
impl FormatNodeRule<TsConstModifier> for FormatTsConstModifier {
fn fmt_fields(&self, node: &TsConstModifier, f: &mut JsFormatter) -> FormatResult<()> {
let TsConstModifierFields { modifier_token } = node.as_fields();
write![f, [modifier_token.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/enum_member.rs | crates/rome_js_formatter/src/ts/auxiliary/enum_member.rs | use crate::prelude::*;
use crate::utils::FormatInitializerClause;
use rome_formatter::write;
use rome_js_syntax::{TsEnumMember, TsEnumMemberFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsEnumMember;
impl FormatNodeRule<TsEnumMember> for FormatTsEnumMember {
fn fmt_fields(&self, node: &TsEnumMember, f: &mut JsFormatter) -> FormatResult<()> {
let TsEnumMemberFields { name, initializer } = node.as_fields();
write!(
f,
[
name.format(),
FormatInitializerClause::new(initializer.as_ref())
]
)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/mapped_type_as_clause.rs | crates/rome_js_formatter/src/ts/auxiliary/mapped_type_as_clause.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::{TsMappedTypeAsClause, TsMappedTypeAsClauseFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsMappedTypeAsClause;
impl FormatNodeRule<TsMappedTypeAsClause> for FormatTsMappedTypeAsClause {
fn fmt_fields(&self, node: &TsMappedTypeAsClause, f: &mut JsFormatter) -> FormatResult<()> {
let TsMappedTypeAsClauseFields { as_token, ty } = node.as_fields();
write![f, [as_token.format(), space(), ty.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/return_type_annotation.rs | crates/rome_js_formatter/src/ts/auxiliary/return_type_annotation.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsReturnTypeAnnotation;
use rome_js_syntax::TsReturnTypeAnnotationFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsReturnTypeAnnotation;
impl FormatNodeRule<TsReturnTypeAnnotation> for FormatTsReturnTypeAnnotation {
fn fmt_fields(&self, node: &TsReturnTypeAnnotation, f: &mut JsFormatter) -> FormatResult<()> {
let TsReturnTypeAnnotationFields { colon_token, ty } = node.as_fields();
write![f, [colon_token.format(), space(), ty.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/accessibility_modifier.rs | crates/rome_js_formatter/src/ts/auxiliary/accessibility_modifier.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsAccessibilityModifier;
use rome_js_syntax::TsAccessibilityModifierFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsAccessibilityModifier;
impl FormatNodeRule<TsAccessibilityModifier> for FormatTsAccessibilityModifier {
fn fmt_fields(&self, node: &TsAccessibilityModifier, f: &mut JsFormatter) -> FormatResult<()> {
let TsAccessibilityModifierFields { modifier_token } = node.as_fields();
write![f, [modifier_token.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/module_block.rs | crates/rome_js_formatter/src/ts/auxiliary/module_block.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsModuleBlock;
use rome_js_syntax::TsModuleBlockFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsModuleBlock;
impl FormatNodeRule<TsModuleBlock> for FormatTsModuleBlock {
fn fmt_fields(&self, node: &TsModuleBlock, f: &mut JsFormatter) -> FormatResult<()> {
let TsModuleBlockFields {
l_curly_token,
items,
r_curly_token,
} = node.as_fields();
write!(f, [l_curly_token.format()])?;
if items.is_empty() {
write!(
f,
[format_dangling_comments(node.syntax()).with_block_indent()]
)?;
} else {
write!(f, [block_indent(&items.format())])?;
}
write!(f, [r_curly_token.format()])
}
fn fmt_dangling_comments(&self, _: &TsModuleBlock, _: &mut JsFormatter) -> FormatResult<()> {
// Handled inside `fmt_fields`
Ok(())
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/default_type_clause.rs | crates/rome_js_formatter/src/ts/auxiliary/default_type_clause.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::{TsDefaultTypeClause, TsDefaultTypeClauseFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsDefaultTypeClause;
impl FormatNodeRule<TsDefaultTypeClause> for FormatTsDefaultTypeClause {
fn fmt_fields(&self, node: &TsDefaultTypeClause, f: &mut JsFormatter) -> FormatResult<()> {
let TsDefaultTypeClauseFields { eq_token, ty } = node.as_fields();
write![f, [eq_token.format(), space(), ty.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/out_modifier.rs | crates/rome_js_formatter/src/ts/auxiliary/out_modifier.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::{TsOutModifier, TsOutModifierFields};
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatTsOutModifier;
impl FormatNodeRule<TsOutModifier> for FormatTsOutModifier {
fn fmt_fields(&self, node: &TsOutModifier, f: &mut JsFormatter) -> FormatResult<()> {
let TsOutModifierFields { modifier_token } = node.as_fields();
write![f, [modifier_token.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/optional_tuple_type_element.rs | crates/rome_js_formatter/src/ts/auxiliary/optional_tuple_type_element.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::{TsOptionalTupleTypeElement, TsOptionalTupleTypeElementFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsOptionalTupleTypeElement;
impl FormatNodeRule<TsOptionalTupleTypeElement> for FormatTsOptionalTupleTypeElement {
fn fmt_fields(
&self,
node: &TsOptionalTupleTypeElement,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsOptionalTupleTypeElementFields {
ty,
question_mark_token,
} = node.as_fields();
let ty = ty.format();
let question_mark = question_mark_token.format();
write![f, [ty, question_mark]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/qualified_name.rs | crates/rome_js_formatter/src/ts/auxiliary/qualified_name.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsQualifiedName;
use rome_js_syntax::TsQualifiedNameFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsQualifiedName;
impl FormatNodeRule<TsQualifiedName> for FormatTsQualifiedName {
fn fmt_fields(&self, node: &TsQualifiedName, f: &mut JsFormatter) -> FormatResult<()> {
let TsQualifiedNameFields {
left,
dot_token,
right,
} = node.as_fields();
write![f, [left.format(), dot_token.format(), right.format(),]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/template_element.rs | crates/rome_js_formatter/src/ts/auxiliary/template_element.rs | use crate::prelude::*;
use rome_formatter::FormatRuleWithOptions;
use crate::js::auxiliary::template_element::{
AnyTemplateElement, FormatTemplateElement, TemplateElementOptions,
};
use rome_js_syntax::TsTemplateElement;
#[derive(Debug, Clone, Default)]
pub struct FormatTsTemplateElement {
options: TemplateElementOptions,
}
impl FormatRuleWithOptions<TsTemplateElement> for FormatTsTemplateElement {
type Options = TemplateElementOptions;
fn with_options(mut self, options: Self::Options) -> Self {
self.options = options;
self
}
}
impl FormatNodeRule<TsTemplateElement> for FormatTsTemplateElement {
fn fmt_fields(
&self,
node: &TsTemplateElement,
formatter: &mut JsFormatter,
) -> FormatResult<()> {
let element = AnyTemplateElement::from(node.clone());
FormatTemplateElement::new(element, self.options).fmt(formatter)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/property_signature_type_member.rs | crates/rome_js_formatter/src/ts/auxiliary/property_signature_type_member.rs | use crate::prelude::*;
use crate::utils::FormatTypeMemberSeparator;
use rome_formatter::write;
use rome_js_syntax::{TsPropertySignatureTypeMember, TsPropertySignatureTypeMemberFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsPropertySignatureTypeMember;
impl FormatNodeRule<TsPropertySignatureTypeMember> for FormatTsPropertySignatureTypeMember {
fn fmt_fields(
&self,
node: &TsPropertySignatureTypeMember,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsPropertySignatureTypeMemberFields {
readonly_token,
name,
optional_token,
type_annotation,
separator_token,
} = node.as_fields();
write![
f,
[
readonly_token.format(),
space(),
name.format(),
optional_token.format(),
type_annotation.format(),
FormatTypeMemberSeparator::new(separator_token.as_ref())
]
]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/definite_property_annotation.rs | crates/rome_js_formatter/src/ts/auxiliary/definite_property_annotation.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsDefinitePropertyAnnotation;
use rome_js_syntax::TsDefinitePropertyAnnotationFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsDefinitePropertyAnnotation;
impl FormatNodeRule<TsDefinitePropertyAnnotation> for FormatTsDefinitePropertyAnnotation {
fn fmt_fields(
&self,
node: &TsDefinitePropertyAnnotation,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsDefinitePropertyAnnotationFields {
excl_token,
type_annotation,
} = node.as_fields();
write![f, [excl_token.format(), type_annotation.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/construct_signature_type_member.rs | crates/rome_js_formatter/src/ts/auxiliary/construct_signature_type_member.rs | use crate::prelude::*;
use rome_formatter::{format_args, write};
use crate::utils::FormatTypeMemberSeparator;
use rome_js_syntax::{TsConstructSignatureTypeMember, TsConstructSignatureTypeMemberFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsConstructSignatureTypeMember;
impl FormatNodeRule<TsConstructSignatureTypeMember> for FormatTsConstructSignatureTypeMember {
fn fmt_fields(
&self,
node: &TsConstructSignatureTypeMember,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsConstructSignatureTypeMemberFields {
new_token,
type_parameters,
parameters,
type_annotation,
separator_token,
} = node.as_fields();
write![
f,
[
new_token.format(),
space(),
group(&format_args![type_parameters.format(), parameters.format()]),
type_annotation.format(),
FormatTypeMemberSeparator::new(separator_token.as_ref()),
]
]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/mapped_type_readonly_modifier_clause.rs | crates/rome_js_formatter/src/ts/auxiliary/mapped_type_readonly_modifier_clause.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsMappedTypeReadonlyModifierClause;
use rome_js_syntax::TsMappedTypeReadonlyModifierClauseFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsMappedTypeReadonlyModifierClause;
impl FormatNodeRule<TsMappedTypeReadonlyModifierClause>
for FormatTsMappedTypeReadonlyModifierClause
{
fn fmt_fields(
&self,
node: &TsMappedTypeReadonlyModifierClause,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsMappedTypeReadonlyModifierClauseFields {
operator_token,
readonly_token,
} = node.as_fields();
write![f, [operator_token.format(), readonly_token.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/definite_variable_annotation.rs | crates/rome_js_formatter/src/ts/auxiliary/definite_variable_annotation.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsDefiniteVariableAnnotation;
use rome_js_syntax::TsDefiniteVariableAnnotationFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsDefiniteVariableAnnotation;
impl FormatNodeRule<TsDefiniteVariableAnnotation> for FormatTsDefiniteVariableAnnotation {
fn fmt_fields(
&self,
node: &TsDefiniteVariableAnnotation,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsDefiniteVariableAnnotationFields {
excl_token,
type_annotation,
} = node.as_fields();
write![f, [excl_token.format(), type_annotation.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/type_annotation.rs | crates/rome_js_formatter/src/ts/auxiliary/type_annotation.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::{TsTypeAnnotation, TsTypeAnnotationFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsTypeAnnotation;
impl FormatNodeRule<TsTypeAnnotation> for FormatTsTypeAnnotation {
fn fmt_fields(&self, node: &TsTypeAnnotation, f: &mut JsFormatter) -> FormatResult<()> {
let TsTypeAnnotationFields { colon_token, ty } = node.as_fields();
let colon = colon_token.format();
let ty = ty.format();
write![f, [colon, space(), ty]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/mod.rs | crates/rome_js_formatter/src/ts/auxiliary/mod.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
pub(crate) mod abstract_modifier;
pub(crate) mod accessibility_modifier;
pub(crate) mod asserts_condition;
pub(crate) mod call_signature_type_member;
pub(crate) mod const_modifier;
pub(crate) mod construct_signature_type_member;
pub(crate) mod declare_modifier;
pub(crate) mod default_type_clause;
pub(crate) mod definite_property_annotation;
pub(crate) mod definite_variable_annotation;
pub(crate) mod empty_external_module_declaration_body;
pub(crate) mod enum_member;
pub(crate) mod external_module_reference;
pub(crate) mod getter_signature_type_member;
pub(crate) mod implements_clause;
pub(crate) mod in_modifier;
pub(crate) mod index_signature_type_member;
pub(crate) mod mapped_type_as_clause;
pub(crate) mod mapped_type_optional_modifier_clause;
pub(crate) mod mapped_type_readonly_modifier_clause;
pub(crate) mod method_signature_type_member;
pub(crate) mod module_block;
pub(crate) mod named_tuple_type_element;
pub(crate) mod optional_property_annotation;
pub(crate) mod optional_tuple_type_element;
pub(crate) mod out_modifier;
pub(crate) mod override_modifier;
pub(crate) mod property_signature_type_member;
pub(crate) mod qualified_module_name;
pub(crate) mod qualified_name;
pub(crate) mod readonly_modifier;
pub(crate) mod rest_tuple_type_element;
pub(crate) mod return_type_annotation;
pub(crate) mod setter_signature_type_member;
pub(crate) mod template_chunk_element;
pub(crate) mod template_element;
pub(crate) mod type_annotation;
pub(crate) mod type_constraint_clause;
pub(crate) mod type_parameter_name;
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/named_tuple_type_element.rs | crates/rome_js_formatter/src/ts/auxiliary/named_tuple_type_element.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::{TsNamedTupleTypeElement, TsNamedTupleTypeElementFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsNamedTupleTypeElement;
impl FormatNodeRule<TsNamedTupleTypeElement> for FormatTsNamedTupleTypeElement {
fn fmt_fields(&self, node: &TsNamedTupleTypeElement, f: &mut JsFormatter) -> FormatResult<()> {
let TsNamedTupleTypeElementFields {
ty,
question_mark_token,
colon_token,
name,
dotdotdot_token,
} = node.as_fields();
write![
f,
[
dotdotdot_token.format(),
name.format(),
question_mark_token.format(),
colon_token.format(),
space(),
ty.format(),
]
]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/getter_signature_type_member.rs | crates/rome_js_formatter/src/ts/auxiliary/getter_signature_type_member.rs | use crate::prelude::*;
use crate::utils::FormatTypeMemberSeparator;
use rome_formatter::write;
use rome_js_syntax::{TsGetterSignatureTypeMember, TsGetterSignatureTypeMemberFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsGetterSignatureTypeMember;
impl FormatNodeRule<TsGetterSignatureTypeMember> for FormatTsGetterSignatureTypeMember {
fn fmt_fields(
&self,
node: &TsGetterSignatureTypeMember,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsGetterSignatureTypeMemberFields {
get_token,
name,
l_paren_token,
r_paren_token,
type_annotation,
separator_token,
} = node.as_fields();
write![
f,
[
get_token.format(),
space(),
name.format(),
l_paren_token.format(),
r_paren_token.format(),
type_annotation.format(),
FormatTypeMemberSeparator::new(separator_token.as_ref())
]
]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/abstract_modifier.rs | crates/rome_js_formatter/src/ts/auxiliary/abstract_modifier.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsAbstractModifier;
use rome_js_syntax::TsAbstractModifierFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsAbstractModifier;
impl FormatNodeRule<TsAbstractModifier> for FormatTsAbstractModifier {
fn fmt_fields(&self, node: &TsAbstractModifier, f: &mut JsFormatter) -> FormatResult<()> {
let TsAbstractModifierFields { modifier_token } = node.as_fields();
write![f, [modifier_token.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/template_chunk_element.rs | crates/rome_js_formatter/src/ts/auxiliary/template_chunk_element.rs | use crate::prelude::*;
use crate::js::auxiliary::template_chunk_element::AnyTemplateChunkElement;
use rome_js_syntax::TsTemplateChunkElement;
#[derive(Debug, Clone, Default)]
pub struct FormatTsTemplateChunkElement;
impl FormatNodeRule<TsTemplateChunkElement> for FormatTsTemplateChunkElement {
fn fmt_fields(
&self,
node: &TsTemplateChunkElement,
formatter: &mut JsFormatter,
) -> FormatResult<()> {
AnyTemplateChunkElement::from(node.clone()).fmt(formatter)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/type_constraint_clause.rs | crates/rome_js_formatter/src/ts/auxiliary/type_constraint_clause.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::{TsTypeConstraintClause, TsTypeConstraintClauseFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsTypeConstraintClause;
impl FormatNodeRule<TsTypeConstraintClause> for FormatTsTypeConstraintClause {
fn fmt_fields(&self, node: &TsTypeConstraintClause, f: &mut JsFormatter) -> FormatResult<()> {
let TsTypeConstraintClauseFields { extends_token, ty } = node.as_fields();
let extends = extends_token.format();
let ty = ty.format();
write![f, [extends, space(), ty]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/readonly_modifier.rs | crates/rome_js_formatter/src/ts/auxiliary/readonly_modifier.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsReadonlyModifier;
use rome_js_syntax::TsReadonlyModifierFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsReadonlyModifier;
impl FormatNodeRule<TsReadonlyModifier> for FormatTsReadonlyModifier {
fn fmt_fields(&self, node: &TsReadonlyModifier, f: &mut JsFormatter) -> FormatResult<()> {
let TsReadonlyModifierFields { modifier_token } = node.as_fields();
write![f, [modifier_token.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/declare_modifier.rs | crates/rome_js_formatter/src/ts/auxiliary/declare_modifier.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsDeclareModifier;
use rome_js_syntax::TsDeclareModifierFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsDeclareModifier;
impl FormatNodeRule<TsDeclareModifier> for FormatTsDeclareModifier {
fn fmt_fields(&self, node: &TsDeclareModifier, f: &mut JsFormatter) -> FormatResult<()> {
let TsDeclareModifierFields { modifier_token } = node.as_fields();
write![f, [modifier_token.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/asserts_condition.rs | crates/rome_js_formatter/src/ts/auxiliary/asserts_condition.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsAssertsCondition;
use rome_js_syntax::TsAssertsConditionFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsAssertsCondition;
impl FormatNodeRule<TsAssertsCondition> for FormatTsAssertsCondition {
fn fmt_fields(&self, node: &TsAssertsCondition, f: &mut JsFormatter) -> FormatResult<()> {
let TsAssertsConditionFields { is_token, ty } = node.as_fields();
write![f, [is_token.format(), space(), ty.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/call_signature_type_member.rs | crates/rome_js_formatter/src/ts/auxiliary/call_signature_type_member.rs | use crate::prelude::*;
use crate::utils::FormatTypeMemberSeparator;
use rome_formatter::{format_args, write};
use rome_js_syntax::{TsCallSignatureTypeMember, TsCallSignatureTypeMemberFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsCallSignatureTypeMember;
impl FormatNodeRule<TsCallSignatureTypeMember> for FormatTsCallSignatureTypeMember {
fn fmt_fields(
&self,
node: &TsCallSignatureTypeMember,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsCallSignatureTypeMemberFields {
type_parameters,
parameters,
return_type_annotation,
separator_token,
} = node.as_fields();
write!(
f,
[
group(&format_args![type_parameters.format(), parameters.format()]),
return_type_annotation.format(),
FormatTypeMemberSeparator::new(separator_token.as_ref())
]
)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/method_signature_type_member.rs | crates/rome_js_formatter/src/ts/auxiliary/method_signature_type_member.rs | use crate::prelude::*;
use crate::utils::FormatTypeMemberSeparator;
use crate::js::classes::method_class_member::FormatAnyJsMethodMember;
use rome_formatter::write;
use rome_js_syntax::TsMethodSignatureTypeMember;
#[derive(Debug, Clone, Default)]
pub struct FormatTsMethodSignatureTypeMember;
impl FormatNodeRule<TsMethodSignatureTypeMember> for FormatTsMethodSignatureTypeMember {
fn fmt_fields(
&self,
node: &TsMethodSignatureTypeMember,
f: &mut JsFormatter,
) -> FormatResult<()> {
write![
f,
[
FormatAnyJsMethodMember::from(node.clone()),
FormatTypeMemberSeparator::new(node.separator_token().as_ref())
]
]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/in_modifier.rs | crates/rome_js_formatter/src/ts/auxiliary/in_modifier.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::{TsInModifier, TsInModifierFields};
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatTsInModifier;
impl FormatNodeRule<TsInModifier> for FormatTsInModifier {
fn fmt_fields(&self, node: &TsInModifier, f: &mut JsFormatter) -> FormatResult<()> {
let TsInModifierFields { modifier_token } = node.as_fields();
write![f, [modifier_token.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/implements_clause.rs | crates/rome_js_formatter/src/ts/auxiliary/implements_clause.rs | use crate::prelude::*;
use rome_formatter::{format_args, write};
use rome_js_syntax::TsImplementsClause;
use rome_js_syntax::TsImplementsClauseFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsImplementsClause;
impl FormatNodeRule<TsImplementsClause> for FormatTsImplementsClause {
fn fmt_fields(&self, node: &TsImplementsClause, f: &mut JsFormatter) -> FormatResult<()> {
let TsImplementsClauseFields {
implements_token,
types,
} = node.as_fields();
write!(
f,
[
implements_token.format(),
group(&indent(&format_args![
soft_line_break_or_space(),
types.format()
]))
]
)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/external_module_reference.rs | crates/rome_js_formatter/src/ts/auxiliary/external_module_reference.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsExternalModuleReference;
use rome_js_syntax::TsExternalModuleReferenceFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsExternalModuleReference;
impl FormatNodeRule<TsExternalModuleReference> for FormatTsExternalModuleReference {
fn fmt_fields(
&self,
node: &TsExternalModuleReference,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsExternalModuleReferenceFields {
require_token,
l_paren_token,
source,
r_paren_token,
} = node.as_fields();
write![
f,
[
require_token.format(),
l_paren_token.format(),
source.format(),
r_paren_token.format(),
]
]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/empty_external_module_declaration_body.rs | crates/rome_js_formatter/src/ts/auxiliary/empty_external_module_declaration_body.rs | use crate::prelude::*;
use crate::utils::FormatOptionalSemicolon;
use rome_formatter::write;
use rome_js_syntax::TsEmptyExternalModuleDeclarationBody;
use rome_js_syntax::TsEmptyExternalModuleDeclarationBodyFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsEmptyExternalModuleDeclarationBody;
impl FormatNodeRule<TsEmptyExternalModuleDeclarationBody>
for FormatTsEmptyExternalModuleDeclarationBody
{
fn fmt_fields(
&self,
node: &TsEmptyExternalModuleDeclarationBody,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsEmptyExternalModuleDeclarationBodyFields { semicolon_token } = node.as_fields();
write![f, [FormatOptionalSemicolon::new(Some(&semicolon_token?))]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/setter_signature_type_member.rs | crates/rome_js_formatter/src/ts/auxiliary/setter_signature_type_member.rs | use crate::prelude::*;
use crate::utils::FormatTypeMemberSeparator;
use rome_formatter::write;
use rome_js_syntax::{TsSetterSignatureTypeMember, TsSetterSignatureTypeMemberFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsSetterSignatureTypeMember;
impl FormatNodeRule<TsSetterSignatureTypeMember> for FormatTsSetterSignatureTypeMember {
fn fmt_fields(
&self,
node: &TsSetterSignatureTypeMember,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsSetterSignatureTypeMemberFields {
set_token,
name,
l_paren_token,
parameter,
r_paren_token,
separator_token,
} = node.as_fields();
write![
f,
[
set_token.format(),
space(),
name.format(),
l_paren_token.format(),
parameter.format(),
r_paren_token.format(),
FormatTypeMemberSeparator::new(separator_token.as_ref())
]
]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/auxiliary/rest_tuple_type_element.rs | crates/rome_js_formatter/src/ts/auxiliary/rest_tuple_type_element.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::{TsRestTupleTypeElement, TsRestTupleTypeElementFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsRestTupleTypeElement;
impl FormatNodeRule<TsRestTupleTypeElement> for FormatTsRestTupleTypeElement {
fn fmt_fields(&self, node: &TsRestTupleTypeElement, f: &mut JsFormatter) -> FormatResult<()> {
let TsRestTupleTypeElementFields {
dotdotdot_token,
ty,
} = node.as_fields();
let dotdotdot = dotdotdot_token.format();
let ty = ty.format();
write![f, [dotdotdot, ty]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/expressions/non_null_assertion_expression.rs | crates/rome_js_formatter/src/ts/expressions/non_null_assertion_expression.rs | use crate::prelude::*;
use crate::js::expressions::static_member_expression::member_chain_callee_needs_parens;
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::{JsSyntaxKind, TsNonNullAssertionExpressionFields};
use rome_js_syntax::{JsSyntaxNode, TsNonNullAssertionExpression};
#[derive(Debug, Clone, Default)]
pub struct FormatTsNonNullAssertionExpression;
impl FormatNodeRule<TsNonNullAssertionExpression> for FormatTsNonNullAssertionExpression {
fn fmt_fields(
&self,
node: &TsNonNullAssertionExpression,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsNonNullAssertionExpressionFields {
expression,
excl_token,
} = node.as_fields();
write![f, [expression.format(), excl_token.format()]]
}
fn needs_parentheses(&self, item: &TsNonNullAssertionExpression) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsNonNullAssertionExpression {
fn needs_parentheses_with_parent(&self, parent: &JsSyntaxNode) -> bool {
matches!(parent.kind(), JsSyntaxKind::JS_EXTENDS_CLAUSE)
|| member_chain_callee_needs_parens(self.clone().into(), parent)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/expressions/as_expression.rs | crates/rome_js_formatter/src/ts/expressions/as_expression.rs | use crate::prelude::*;
use crate::parentheses::{
is_binary_like_left_or_right, is_callee, is_member_object, NeedsParentheses,
};
use crate::ts::expressions::type_assertion_expression::type_cast_like_needs_parens;
use rome_formatter::{format_args, write};
use rome_js_syntax::{AnyJsExpression, JsSyntaxKind, JsSyntaxNode, JsSyntaxToken, TsAsExpression};
use rome_js_syntax::{AnyTsType, TsSatisfiesExpression};
use rome_rowan::{declare_node_union, SyntaxResult};
#[derive(Debug, Clone, Default)]
pub struct FormatTsAsExpression;
impl FormatNodeRule<TsAsExpression> for FormatTsAsExpression {
fn fmt_fields(&self, node: &TsAsExpression, f: &mut JsFormatter) -> FormatResult<()> {
TsAsOrSatisfiesExpression::from(node.clone()).fmt(f)
}
fn needs_parentheses(&self, item: &TsAsExpression) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsAsExpression {
fn needs_parentheses_with_parent(&self, parent: &JsSyntaxNode) -> bool {
TsAsOrSatisfiesExpression::from(self.clone()).needs_parentheses_with_parent(parent)
}
}
declare_node_union! {
pub(crate) TsAsOrSatisfiesExpression = TsAsExpression | TsSatisfiesExpression
}
impl TsAsOrSatisfiesExpression {
fn ty(&self) -> SyntaxResult<AnyTsType> {
match self {
TsAsOrSatisfiesExpression::TsAsExpression(expression) => expression.ty(),
TsAsOrSatisfiesExpression::TsSatisfiesExpression(expression) => expression.ty(),
}
}
fn operation_token(&self) -> SyntaxResult<JsSyntaxToken> {
match self {
TsAsOrSatisfiesExpression::TsAsExpression(expression) => expression.as_token(),
TsAsOrSatisfiesExpression::TsSatisfiesExpression(expression) => {
expression.satisfies_token()
}
}
}
fn expression(&self) -> SyntaxResult<AnyJsExpression> {
match self {
TsAsOrSatisfiesExpression::TsAsExpression(expression) => expression.expression(),
TsAsOrSatisfiesExpression::TsSatisfiesExpression(expression) => expression.expression(),
}
}
}
impl Format<JsFormatContext> for TsAsOrSatisfiesExpression {
fn fmt(&self, f: &mut JsFormatter) -> FormatResult<()> {
let expression = self.expression();
let operation_token = self.operation_token()?;
let ty = self.ty()?;
let format_inner = format_with(|f| {
write!(f, [expression.format(), space(), operation_token.format()])?;
if f.comments().has_leading_own_line_comment(ty.syntax()) {
write!(f, [indent(&format_args![hard_line_break(), &ty.format()])])
} else {
write!(f, [space(), ty.format()])
}
});
let parent = self.syntax().parent();
let is_callee_or_object = parent.map_or(false, |parent| {
is_callee(self.syntax(), &parent) || is_member_object(self.syntax(), &parent)
});
if is_callee_or_object {
write!(f, [group(&soft_block_indent(&format_inner))])
} else {
write!(f, [format_inner])
}
}
}
impl NeedsParentheses for TsAsOrSatisfiesExpression {
fn needs_parentheses_with_parent(&self, parent: &JsSyntaxNode) -> bool {
match parent.kind() {
JsSyntaxKind::JS_CONDITIONAL_EXPRESSION => true,
_ => {
type_cast_like_needs_parens(self.syntax(), parent)
|| is_binary_like_left_or_right(self.syntax(), parent)
}
}
}
}
#[cfg(test)]
mod tests {
use crate::{assert_needs_parentheses, assert_not_needs_parentheses};
use rome_js_syntax::{JsFileSource, TsAsExpression};
#[test]
fn needs_parentheses() {
assert_needs_parentheses!("5 as number ? true : false", TsAsExpression);
assert_needs_parentheses!("cond ? x as number : false", TsAsExpression);
assert_needs_parentheses!("cond ? true : x as number", TsAsExpression);
assert_needs_parentheses!("class X extends (B as number) {}", TsAsExpression);
assert_needs_parentheses!("(x as Function)()", TsAsExpression);
assert_needs_parentheses!("(x as Function)?.()", TsAsExpression);
assert_needs_parentheses!("new (x as Function)()", TsAsExpression);
assert_needs_parentheses!("<number>(x as any)", TsAsExpression);
assert_needs_parentheses!("(x as any)`template`", TsAsExpression);
assert_needs_parentheses!("!(x as any)", TsAsExpression);
assert_needs_parentheses!("[...(x as any)]", TsAsExpression);
assert_needs_parentheses!("({...(x as any)})", TsAsExpression);
assert_needs_parentheses!(
"<test {...(x as any)} />",
TsAsExpression,
JsFileSource::tsx()
);
assert_needs_parentheses!(
"<test>{...(x as any)}</test>",
TsAsExpression,
JsFileSource::tsx()
);
assert_needs_parentheses!("await (x as any)", TsAsExpression);
assert_needs_parentheses!("(x as any)!", TsAsExpression);
assert_needs_parentheses!("(x as any).member", TsAsExpression);
assert_needs_parentheses!("(x as any)[member]", TsAsExpression);
assert_not_needs_parentheses!("object[x as any]", TsAsExpression);
assert_needs_parentheses!("(x as any) + (y as any)", TsAsExpression[0]);
assert_needs_parentheses!("(x as any) + (y as any)", TsAsExpression[1]);
assert_needs_parentheses!("(x as any) && (y as any)", TsAsExpression[0]);
assert_needs_parentheses!("(x as any) && (y as any)", TsAsExpression[1]);
assert_needs_parentheses!("(x as any) in (y as any)", TsAsExpression[0]);
assert_needs_parentheses!("(x as any) in (y as any)", TsAsExpression[1]);
assert_needs_parentheses!("(x as any) instanceof (y as any)", TsAsExpression[0]);
assert_needs_parentheses!("(x as any) instanceof (y as any)", TsAsExpression[1]);
assert_not_needs_parentheses!("x as number as string", TsAsExpression[1]);
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/expressions/satisfies_expression.rs | crates/rome_js_formatter/src/ts/expressions/satisfies_expression.rs | use crate::prelude::*;
use crate::parentheses::NeedsParentheses;
use crate::ts::expressions::as_expression::TsAsOrSatisfiesExpression;
use rome_js_syntax::{JsSyntaxNode, TsSatisfiesExpression};
#[derive(Debug, Clone, Default)]
pub struct FormatTsSatisfiesExpression;
impl FormatNodeRule<TsSatisfiesExpression> for FormatTsSatisfiesExpression {
fn fmt_fields(&self, node: &TsSatisfiesExpression, f: &mut JsFormatter) -> FormatResult<()> {
TsAsOrSatisfiesExpression::from(node.clone()).fmt(f)
}
fn needs_parentheses(&self, item: &TsSatisfiesExpression) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsSatisfiesExpression {
fn needs_parentheses_with_parent(&self, parent: &JsSyntaxNode) -> bool {
TsAsOrSatisfiesExpression::from(self.clone()).needs_parentheses_with_parent(parent)
}
}
#[cfg(test)]
mod tests {
use crate::{assert_needs_parentheses, assert_not_needs_parentheses};
use rome_js_syntax::{JsFileSource, TsSatisfiesExpression};
#[test]
fn needs_parentheses() {
assert_needs_parentheses!("5 satisfies number ? true : false", TsSatisfiesExpression);
assert_needs_parentheses!("cond ? x satisfies number : false", TsSatisfiesExpression);
assert_needs_parentheses!("cond ? true : x satisfies number", TsSatisfiesExpression);
assert_needs_parentheses!(
"class X extends (B satisfies number) {}",
TsSatisfiesExpression
);
assert_needs_parentheses!("(x satisfies Function)()", TsSatisfiesExpression);
assert_needs_parentheses!("(x satisfies Function)?.()", TsSatisfiesExpression);
assert_needs_parentheses!("new (x satisfies Function)()", TsSatisfiesExpression);
assert_needs_parentheses!("<number>(x satisfies any)", TsSatisfiesExpression);
assert_needs_parentheses!("(x satisfies any)`template`", TsSatisfiesExpression);
assert_needs_parentheses!("!(x satisfies any)", TsSatisfiesExpression);
assert_needs_parentheses!("[...(x satisfies any)]", TsSatisfiesExpression);
assert_needs_parentheses!("({...(x satisfies any)})", TsSatisfiesExpression);
assert_needs_parentheses!(
"<test {...(x satisfies any)} />",
TsSatisfiesExpression,
JsFileSource::tsx()
);
assert_needs_parentheses!(
"<test>{...(x satisfies any)}</test>",
TsSatisfiesExpression,
JsFileSource::tsx()
);
assert_needs_parentheses!("await (x satisfies any)", TsSatisfiesExpression);
assert_needs_parentheses!("(x satisfies any)!", TsSatisfiesExpression);
assert_needs_parentheses!("(x satisfies any).member", TsSatisfiesExpression);
assert_needs_parentheses!("(x satisfies any)[member]", TsSatisfiesExpression);
assert_not_needs_parentheses!("object[x satisfies any]", TsSatisfiesExpression);
assert_needs_parentheses!(
"(x satisfies any) + (y satisfies any)",
TsSatisfiesExpression[0]
);
assert_needs_parentheses!(
"(x satisfies any) + (y satisfies any)",
TsSatisfiesExpression[1]
);
assert_needs_parentheses!(
"(x satisfies any) && (y satisfies any)",
TsSatisfiesExpression[0]
);
assert_needs_parentheses!(
"(x satisfies any) && (y satisfies any)",
TsSatisfiesExpression[1]
);
assert_needs_parentheses!(
"(x satisfies any) in (y satisfies any)",
TsSatisfiesExpression[0]
);
assert_needs_parentheses!(
"(x satisfies any) in (y satisfies any)",
TsSatisfiesExpression[1]
);
assert_needs_parentheses!(
"(x satisfies any) instanceof (y satisfies any)",
TsSatisfiesExpression[0]
);
assert_needs_parentheses!(
"(x satisfies any) instanceof (y satisfies any)",
TsSatisfiesExpression[1]
);
assert_not_needs_parentheses!(
"x satisfies number satisfies string",
TsSatisfiesExpression[1]
);
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/expressions/instantiation_expression.rs | crates/rome_js_formatter/src/ts/expressions/instantiation_expression.rs | use crate::{
parentheses::{unary_like_expression_needs_parentheses, NeedsParentheses},
prelude::*,
};
use rome_formatter::write;
use rome_js_syntax::{TsInstantiationExpression, TsInstantiationExpressionFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsInstantiationExpression;
impl FormatNodeRule<TsInstantiationExpression> for FormatTsInstantiationExpression {
fn fmt_fields(
&self,
node: &TsInstantiationExpression,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsInstantiationExpressionFields {
expression,
arguments,
} = node.as_fields();
write![f, [expression.format(), arguments.format()]]
}
}
impl NeedsParentheses for TsInstantiationExpression {
fn needs_parentheses_with_parent(&self, parent: &rome_js_syntax::JsSyntaxNode) -> bool {
unary_like_expression_needs_parentheses(self.syntax(), parent)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/expressions/type_arguments.rs | crates/rome_js_formatter/src/ts/expressions/type_arguments.rs | use crate::utils::should_hug_type;
use crate::{prelude::*, utils::is_object_like_type};
use rome_formatter::FormatError::SyntaxError;
use rome_formatter::{format_args, write};
use rome_js_syntax::{
AnyJsExpression, AnyTsType, JsSyntaxKind, JsVariableDeclarator, TsTypeArguments,
TsTypeArgumentsFields,
};
#[derive(Debug, Clone, Default)]
pub struct FormatTsTypeArguments;
impl FormatNodeRule<TsTypeArguments> for FormatTsTypeArguments {
fn fmt_fields(&self, node: &TsTypeArguments, f: &mut JsFormatter) -> FormatResult<()> {
let TsTypeArgumentsFields {
l_angle_token,
ts_type_argument_list,
r_angle_token,
} = node.as_fields();
if ts_type_argument_list.is_empty() {
return Err(SyntaxError);
}
// We want to check if we are inside something like this:
// const foo: SomeThing<{ [P in "x" | "y"]: number }> = func();
//
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^
// |_________________________|
// that's where we start from
let is_arrow_function_variables = {
match ts_type_argument_list.first() {
// first argument is not mapped type or object type
Some(Ok(ty)) if is_object_like_type(&ty) && ts_type_argument_list.len() == 1 => {
false
}
Some(Ok(ty)) => {
// we then go up until we can find a potential type annotation,
// meaning four levels up
let maybe_type_annotation = ty.syntax().ancestors().nth(4);
let initializer = maybe_type_annotation
.and_then(|maybe_type_annotation| {
if maybe_type_annotation.kind() == JsSyntaxKind::TS_TYPE_ANNOTATION {
maybe_type_annotation.parent()
} else {
None
}
})
// is so, we try to cast the parent into a variable declarator
.and_then(JsVariableDeclarator::cast)
// we extract the initializer
.and_then(|variable_declarator| variable_declarator.initializer());
if let Some(initializer) = initializer {
// we verify if we have an arrow function expression
let expression = initializer.expression()?;
matches!(expression, AnyJsExpression::JsArrowFunctionExpression(_))
} else {
false
}
}
_ => false,
}
};
let first_argument_can_be_hugged_or_is_null_type = match ts_type_argument_list.first() {
_ if ts_type_argument_list.len() != 1 => false,
Some(Ok(AnyTsType::TsNullLiteralType(_))) => true,
Some(Ok(ty)) => should_hug_type(&ty),
_ => false,
};
let should_inline = !is_arrow_function_variables
&& (ts_type_argument_list.len() == 0 || first_argument_can_be_hugged_or_is_null_type);
if should_inline {
write!(
f,
[
l_angle_token.format(),
ts_type_argument_list.format(),
r_angle_token.format()
]
)
} else {
write!(
f,
[group(&format_args![
l_angle_token.format(),
soft_block_indent(&ts_type_argument_list.format()),
r_angle_token.format()
])]
)
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/expressions/mod.rs | crates/rome_js_formatter/src/ts/expressions/mod.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
pub(crate) mod as_expression;
pub(crate) mod instantiation_expression;
pub(crate) mod name_with_type_arguments;
pub(crate) mod non_null_assertion_expression;
pub(crate) mod satisfies_expression;
pub(crate) mod type_arguments;
pub(crate) mod type_assertion_expression;
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/expressions/name_with_type_arguments.rs | crates/rome_js_formatter/src/ts/expressions/name_with_type_arguments.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::{TsNameWithTypeArguments, TsNameWithTypeArgumentsFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsNameWithTypeArguments;
impl FormatNodeRule<TsNameWithTypeArguments> for FormatTsNameWithTypeArguments {
fn fmt_fields(&self, node: &TsNameWithTypeArguments, f: &mut JsFormatter) -> FormatResult<()> {
let TsNameWithTypeArgumentsFields {
name,
type_arguments,
} = node.as_fields();
write![f, [name.format(), type_arguments.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/expressions/type_assertion_expression.rs | crates/rome_js_formatter/src/ts/expressions/type_assertion_expression.rs | use crate::prelude::*;
use crate::parentheses::{is_callee, is_member_object, is_spread, is_tag, NeedsParentheses};
use rome_formatter::{format_args, write};
use rome_js_syntax::{AnyJsExpression, JsSyntaxNode};
use rome_js_syntax::{JsSyntaxKind, TsTypeAssertionExpression, TsTypeAssertionExpressionFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsTypeAssertionExpression;
impl FormatNodeRule<TsTypeAssertionExpression> for FormatTsTypeAssertionExpression {
fn fmt_fields(
&self,
node: &TsTypeAssertionExpression,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsTypeAssertionExpressionFields {
l_angle_token,
ty,
r_angle_token,
expression,
} = node.as_fields();
let expression = expression?;
let break_after_cast = !matches!(
expression,
AnyJsExpression::JsArrayExpression(_) | AnyJsExpression::JsObjectExpression(_)
);
let format_cast = format_with(|f| {
write!(
f,
[
l_angle_token.format(),
group(&soft_block_indent(&ty.format())),
r_angle_token.format(),
]
)
});
if break_after_cast {
let format_cast = format_cast.memoized();
let format_expression = expression.format().memoized();
write!(
f,
[best_fitting![
format_args![format_cast, format_expression],
format_args![
format_cast,
group(&format_args![
text("("),
block_indent(&format_expression),
text(")")
])
],
format_args![format_cast, format_expression]
]]
)
} else {
write![f, [format_cast, expression.format()]]
}
}
fn needs_parentheses(&self, item: &TsTypeAssertionExpression) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsTypeAssertionExpression {
fn needs_parentheses_with_parent(&self, parent: &JsSyntaxNode) -> bool {
match parent.kind() {
JsSyntaxKind::TS_AS_EXPRESSION => true,
JsSyntaxKind::TS_SATISFIES_EXPRESSION => true,
_ => type_cast_like_needs_parens(self.syntax(), parent),
}
}
}
pub(super) fn type_cast_like_needs_parens(node: &JsSyntaxNode, parent: &JsSyntaxNode) -> bool {
debug_assert!(matches!(
node.kind(),
JsSyntaxKind::TS_TYPE_ASSERTION_EXPRESSION
| JsSyntaxKind::TS_AS_EXPRESSION
| JsSyntaxKind::TS_SATISFIES_EXPRESSION
));
match parent.kind() {
JsSyntaxKind::JS_EXTENDS_CLAUSE
| JsSyntaxKind::TS_TYPE_ASSERTION_EXPRESSION
| JsSyntaxKind::JS_UNARY_EXPRESSION
| JsSyntaxKind::JS_AWAIT_EXPRESSION
| JsSyntaxKind::TS_NON_NULL_ASSERTION_EXPRESSION => true,
_ => {
is_callee(node, parent)
|| is_tag(node, parent)
|| is_spread(node, parent)
|| is_member_object(node, parent)
}
}
}
#[cfg(test)]
mod tests {
use crate::{assert_needs_parentheses, assert_not_needs_parentheses};
use rome_js_syntax::TsTypeAssertionExpression;
#[test]
fn needs_parentheses() {
assert_needs_parentheses!("(<number> x) as any", TsTypeAssertionExpression);
assert_needs_parentheses!("class X extends (<number>B) {}", TsTypeAssertionExpression);
assert_needs_parentheses!("(<Function>x)()", TsTypeAssertionExpression);
assert_needs_parentheses!("(<Function>x)?.()", TsTypeAssertionExpression);
assert_needs_parentheses!("new (<Function>x)()", TsTypeAssertionExpression);
assert_needs_parentheses!("<number>(<any>x)", TsTypeAssertionExpression[1]);
assert_needs_parentheses!("<number>(<any>x)", TsTypeAssertionExpression[1]);
assert_needs_parentheses!("(<any>x)`template`", TsTypeAssertionExpression);
assert_needs_parentheses!("!(<any>x)", TsTypeAssertionExpression);
assert_needs_parentheses!("[...(<any>x)]", TsTypeAssertionExpression);
assert_needs_parentheses!("({...(<any>x)})", TsTypeAssertionExpression);
assert_needs_parentheses!("await (<any>x)", TsTypeAssertionExpression);
assert_needs_parentheses!("(<any>x)!", TsTypeAssertionExpression);
assert_needs_parentheses!("(<any>x).member", TsTypeAssertionExpression);
assert_needs_parentheses!("(<any>x)[member]", TsTypeAssertionExpression);
assert_not_needs_parentheses!("object[<any>x]", TsTypeAssertionExpression);
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/module/export_as_namespace_clause.rs | crates/rome_js_formatter/src/ts/module/export_as_namespace_clause.rs | use crate::prelude::*;
use crate::utils::FormatStatementSemicolon;
use rome_formatter::write;
use rome_js_syntax::TsExportAsNamespaceClause;
use rome_js_syntax::TsExportAsNamespaceClauseFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsExportAsNamespaceClause;
impl FormatNodeRule<TsExportAsNamespaceClause> for FormatTsExportAsNamespaceClause {
fn fmt_fields(
&self,
node: &TsExportAsNamespaceClause,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsExportAsNamespaceClauseFields {
as_token,
namespace_token,
name,
semicolon_token,
} = node.as_fields();
write!(
f,
[
as_token.format(),
space(),
namespace_token.format(),
space(),
name.format(),
FormatStatementSemicolon::new(semicolon_token.as_ref())
]
)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/module/import_type.rs | crates/rome_js_formatter/src/ts/module/import_type.rs | use crate::prelude::*;
use crate::utils::{FormatLiteralStringToken, StringLiteralParentKind};
use crate::parentheses::NeedsParentheses;
use rome_formatter::write;
use rome_js_syntax::TsImportTypeFields;
use rome_js_syntax::{JsSyntaxNode, TsImportType};
#[derive(Debug, Clone, Default)]
pub struct FormatTsImportType;
impl FormatNodeRule<TsImportType> for FormatTsImportType {
fn fmt_fields(&self, node: &TsImportType, f: &mut JsFormatter) -> FormatResult<()> {
let TsImportTypeFields {
typeof_token,
import_token,
l_paren_token,
argument_token,
r_paren_token,
qualifier_clause,
type_arguments,
} = node.as_fields();
if let Some(typeof_token) = typeof_token {
write!(f, [typeof_token.format(), space()])?;
}
write![
f,
[
import_token.format(),
l_paren_token.format(),
FormatLiteralStringToken::new(
&argument_token?,
StringLiteralParentKind::Expression
),
r_paren_token.format(),
qualifier_clause.format(),
type_arguments.format(),
]
]
}
fn needs_parentheses(&self, item: &TsImportType) -> bool {
item.needs_parentheses()
}
}
impl NeedsParentheses for TsImportType {
fn needs_parentheses_with_parent(&self, _parent: &JsSyntaxNode) -> bool {
false
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/module/export_assignment_clause.rs | crates/rome_js_formatter/src/ts/module/export_assignment_clause.rs | use crate::prelude::*;
use crate::utils::FormatStatementSemicolon;
use rome_formatter::write;
use rome_js_syntax::TsExportAssignmentClause;
use rome_js_syntax::TsExportAssignmentClauseFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsExportAssignmentClause;
impl FormatNodeRule<TsExportAssignmentClause> for FormatTsExportAssignmentClause {
fn fmt_fields(&self, node: &TsExportAssignmentClause, f: &mut JsFormatter) -> FormatResult<()> {
let TsExportAssignmentClauseFields {
eq_token,
expression,
semicolon_token,
} = node.as_fields();
write!(
f,
[
eq_token.format(),
space(),
expression.format(),
FormatStatementSemicolon::new(semicolon_token.as_ref())
]
)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/module/import_type_qualifier.rs | crates/rome_js_formatter/src/ts/module/import_type_qualifier.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsImportTypeQualifier;
use rome_js_syntax::TsImportTypeQualifierFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsImportTypeQualifier;
impl FormatNodeRule<TsImportTypeQualifier> for FormatTsImportTypeQualifier {
fn fmt_fields(&self, node: &TsImportTypeQualifier, f: &mut JsFormatter) -> FormatResult<()> {
let TsImportTypeQualifierFields { dot_token, right } = node.as_fields();
write![f, [dot_token.format(), right.format()]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/module/mod.rs | crates/rome_js_formatter/src/ts/module/mod.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
pub(crate) mod export_as_namespace_clause;
pub(crate) mod export_assignment_clause;
pub(crate) mod export_declare_clause;
pub(crate) mod import_type;
pub(crate) mod import_type_qualifier;
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/module/export_declare_clause.rs | crates/rome_js_formatter/src/ts/module/export_declare_clause.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::TsExportDeclareClause;
use rome_js_syntax::TsExportDeclareClauseFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsExportDeclareClause;
impl FormatNodeRule<TsExportDeclareClause> for FormatTsExportDeclareClause {
fn fmt_fields(&self, node: &TsExportDeclareClause, f: &mut JsFormatter) -> FormatResult<()> {
let TsExportDeclareClauseFields {
declare_token,
declaration,
} = node.as_fields();
write![f, [declare_token.format(), space(), declaration.format(),]]
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/classes/initialized_property_signature_class_member.rs | crates/rome_js_formatter/src/ts/classes/initialized_property_signature_class_member.rs | use crate::js::classes::property_class_member::{
AnyJsPropertyClassMember, FormatClassPropertySemicolon,
};
use crate::prelude::*;
use crate::utils::AnyJsAssignmentLike;
use rome_formatter::write;
use rome_js_syntax::TsInitializedPropertySignatureClassMember;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatTsInitializedPropertySignatureClassMember;
impl FormatNodeRule<TsInitializedPropertySignatureClassMember>
for FormatTsInitializedPropertySignatureClassMember
{
fn fmt_fields(
&self,
node: &TsInitializedPropertySignatureClassMember,
f: &mut JsFormatter,
) -> FormatResult<()> {
let semicolon_token = node.semicolon_token();
write!(
f,
[
AnyJsAssignmentLike::from(node.clone()),
FormatClassPropertySemicolon::new(
&AnyJsPropertyClassMember::from(node.clone()),
semicolon_token.as_ref()
)
]
)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/classes/method_signature_class_member.rs | crates/rome_js_formatter/src/ts/classes/method_signature_class_member.rs | use crate::prelude::*;
use crate::utils::FormatOptionalSemicolon;
use crate::js::classes::method_class_member::FormatAnyJsMethodMember;
use rome_formatter::write;
use rome_js_syntax::TsMethodSignatureClassMember;
#[derive(Debug, Clone, Default)]
pub struct FormatTsMethodSignatureClassMember;
impl FormatNodeRule<TsMethodSignatureClassMember> for FormatTsMethodSignatureClassMember {
fn fmt_fields(
&self,
node: &TsMethodSignatureClassMember,
f: &mut JsFormatter,
) -> FormatResult<()> {
let modifiers = node.modifiers();
if !modifiers.is_empty() {
write!(f, [modifiers.format(), space()])?;
}
write!(
f,
[
FormatAnyJsMethodMember::from(node.clone()),
FormatOptionalSemicolon::new(node.semicolon_token().as_ref())
]
)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/classes/index_signature_class_member.rs | crates/rome_js_formatter/src/ts/classes/index_signature_class_member.rs | use crate::prelude::*;
use crate::utils::FormatOptionalSemicolon;
use rome_formatter::write;
use rome_js_syntax::TsIndexSignatureClassMember;
use rome_js_syntax::TsIndexSignatureClassMemberFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsIndexSignatureClassMember;
impl FormatNodeRule<TsIndexSignatureClassMember> for FormatTsIndexSignatureClassMember {
fn fmt_fields(
&self,
node: &TsIndexSignatureClassMember,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsIndexSignatureClassMemberFields {
modifiers,
l_brack_token,
parameter,
r_brack_token,
type_annotation,
semicolon_token,
} = node.as_fields();
write!(
f,
[
modifiers.format(),
space(),
l_brack_token.format(),
parameter.format(),
r_brack_token.format(),
type_annotation.format(),
FormatOptionalSemicolon::new(semicolon_token.as_ref())
]
)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/classes/getter_signature_class_member.rs | crates/rome_js_formatter/src/ts/classes/getter_signature_class_member.rs | use crate::prelude::*;
use rome_formatter::write;
use crate::utils::FormatOptionalSemicolon;
use rome_js_syntax::{TsGetterSignatureClassMember, TsGetterSignatureClassMemberFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsGetterSignatureClassMember;
impl FormatNodeRule<TsGetterSignatureClassMember> for FormatTsGetterSignatureClassMember {
fn fmt_fields(
&self,
node: &TsGetterSignatureClassMember,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsGetterSignatureClassMemberFields {
modifiers,
get_token,
name,
l_paren_token,
r_paren_token,
return_type,
semicolon_token,
} = node.as_fields();
write!(
f,
[
modifiers.format(),
space(),
get_token.format(),
space(),
name.format(),
l_paren_token.format(),
r_paren_token.format(),
return_type.format(),
FormatOptionalSemicolon::new(semicolon_token.as_ref())
]
)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/classes/mod.rs | crates/rome_js_formatter/src/ts/classes/mod.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
pub(crate) mod constructor_signature_class_member;
pub(crate) mod extends_clause;
pub(crate) mod getter_signature_class_member;
pub(crate) mod index_signature_class_member;
pub(crate) mod initialized_property_signature_class_member;
pub(crate) mod method_signature_class_member;
pub(crate) mod property_signature_class_member;
pub(crate) mod setter_signature_class_member;
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/classes/setter_signature_class_member.rs | crates/rome_js_formatter/src/ts/classes/setter_signature_class_member.rs | use crate::prelude::*;
use crate::utils::FormatOptionalSemicolon;
use rome_formatter::write;
use rome_js_syntax::{TsSetterSignatureClassMember, TsSetterSignatureClassMemberFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsSetterSignatureClassMember;
impl FormatNodeRule<TsSetterSignatureClassMember> for FormatTsSetterSignatureClassMember {
fn fmt_fields(
&self,
node: &TsSetterSignatureClassMember,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsSetterSignatureClassMemberFields {
modifiers,
set_token,
name,
l_paren_token,
parameter,
r_paren_token,
semicolon_token,
} = node.as_fields();
write!(
f,
[
modifiers.format(),
space(),
set_token.format(),
space(),
name.format(),
l_paren_token.format(),
parameter.format(),
r_paren_token.format(),
FormatOptionalSemicolon::new(semicolon_token.as_ref())
]
)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/classes/property_signature_class_member.rs | crates/rome_js_formatter/src/ts/classes/property_signature_class_member.rs | use crate::js::classes::property_class_member::{
AnyJsPropertyClassMember, FormatClassPropertySemicolon,
};
use crate::prelude::*;
use crate::utils::AnyJsAssignmentLike;
use rome_formatter::write;
use rome_js_syntax::TsPropertySignatureClassMember;
#[derive(Debug, Clone, Default)]
pub struct FormatTsPropertySignatureClassMember;
impl FormatNodeRule<TsPropertySignatureClassMember> for FormatTsPropertySignatureClassMember {
fn fmt_fields(
&self,
node: &TsPropertySignatureClassMember,
f: &mut JsFormatter,
) -> FormatResult<()> {
let semicolon_token = node.semicolon_token();
write!(
f,
[
AnyJsAssignmentLike::from(node.clone()),
FormatClassPropertySemicolon::new(
&AnyJsPropertyClassMember::from(node.clone()),
semicolon_token.as_ref()
)
]
)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/classes/extends_clause.rs | crates/rome_js_formatter/src/ts/classes/extends_clause.rs | use crate::prelude::*;
use rome_formatter::write;
use rome_js_syntax::{TsExtendsClause, TsExtendsClauseFields};
#[derive(Debug, Clone, Default)]
pub struct FormatTsExtendsClause;
impl FormatNodeRule<TsExtendsClause> for FormatTsExtendsClause {
fn fmt_fields(&self, node: &TsExtendsClause, f: &mut JsFormatter) -> FormatResult<()> {
let TsExtendsClauseFields {
extends_token,
types,
} = node.as_fields();
write!(f, [extends_token.format(), space()])?;
if types.len() == 1 {
write!(f, [types.format()])
} else {
write!(f, [indent(&types.format())])
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/classes/constructor_signature_class_member.rs | crates/rome_js_formatter/src/ts/classes/constructor_signature_class_member.rs | use crate::prelude::*;
use crate::utils::FormatOptionalSemicolon;
use rome_formatter::write;
use rome_js_syntax::TsConstructorSignatureClassMember;
use rome_js_syntax::TsConstructorSignatureClassMemberFields;
#[derive(Debug, Clone, Default)]
pub struct FormatTsConstructorSignatureClassMember;
impl FormatNodeRule<TsConstructorSignatureClassMember> for FormatTsConstructorSignatureClassMember {
fn fmt_fields(
&self,
node: &TsConstructorSignatureClassMember,
f: &mut JsFormatter,
) -> FormatResult<()> {
let TsConstructorSignatureClassMemberFields {
modifiers,
name,
parameters,
semicolon_token,
} = node.as_fields();
write!(
f,
[
modifiers.format(),
space(),
name.format(),
group(¶meters.format()),
FormatOptionalSemicolon::new(semicolon_token.as_ref())
]
)
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/any/index_signature_modifier.rs | crates/rome_js_formatter/src/ts/any/index_signature_modifier.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyTsIndexSignatureModifier;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyTsIndexSignatureModifier;
impl FormatRule<AnyTsIndexSignatureModifier> for FormatAnyTsIndexSignatureModifier {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyTsIndexSignatureModifier, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyTsIndexSignatureModifier::JsStaticModifier(node) => node.format().fmt(f),
AnyTsIndexSignatureModifier::TsReadonlyModifier(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/any/external_module_declaration_body.rs | crates/rome_js_formatter/src/ts/any/external_module_declaration_body.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyTsExternalModuleDeclarationBody;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyTsExternalModuleDeclarationBody;
impl FormatRule<AnyTsExternalModuleDeclarationBody> for FormatAnyTsExternalModuleDeclarationBody {
type Context = JsFormatContext;
fn fmt(
&self,
node: &AnyTsExternalModuleDeclarationBody,
f: &mut JsFormatter,
) -> FormatResult<()> {
match node {
AnyTsExternalModuleDeclarationBody::TsEmptyExternalModuleDeclarationBody(node) => {
node.format().fmt(f)
}
AnyTsExternalModuleDeclarationBody::TsModuleBlock(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
rome/tools | https://github.com/rome/tools/blob/392d188a49d70e495f13b1bb08cd7d9c43690f9b/crates/rome_js_formatter/src/ts/any/module_name.rs | crates/rome_js_formatter/src/ts/any/module_name.rs | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyTsModuleName;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyTsModuleName;
impl FormatRule<AnyTsModuleName> for FormatAnyTsModuleName {
type Context = JsFormatContext;
fn fmt(&self, node: &AnyTsModuleName, f: &mut JsFormatter) -> FormatResult<()> {
match node {
AnyTsModuleName::TsIdentifierBinding(node) => node.format().fmt(f),
AnyTsModuleName::TsQualifiedModuleName(node) => node.format().fmt(f),
}
}
}
| rust | MIT | 392d188a49d70e495f13b1bb08cd7d9c43690f9b | 2026-01-04T15:38:12.578592Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.