Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/oxc_ast/src/ast_kind_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ impl AstKind<'_> {
Self::TSUnknownKeyword(_) => "TSUnknownKeyword".into(),
Self::TSInferType(_) => "TSInferType".into(),
Self::TSTemplateLiteralType(_) => "TSTemplateLiteralType".into(),
Self::TSArrayType(_) => "TSArrayType".into(),

Self::TSIndexedAccessType(_) => "TSIndexedAccessType".into(),

Expand Down
112 changes: 60 additions & 52 deletions crates/oxc_ast/src/generated/ast_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,58 +134,59 @@ pub enum AstType {
TSUnionType = 118,
TSIntersectionType = 119,
TSParenthesizedType = 120,
TSIndexedAccessType = 121,
TSNamedTupleMember = 122,
TSAnyKeyword = 123,
TSStringKeyword = 124,
TSBooleanKeyword = 125,
TSNumberKeyword = 126,
TSNeverKeyword = 127,
TSIntrinsicKeyword = 128,
TSUnknownKeyword = 129,
TSNullKeyword = 130,
TSUndefinedKeyword = 131,
TSVoidKeyword = 132,
TSSymbolKeyword = 133,
TSThisType = 134,
TSObjectKeyword = 135,
TSBigIntKeyword = 136,
TSTypeReference = 137,
TSTypeName = 138,
TSQualifiedName = 139,
TSTypeParameterInstantiation = 140,
TSTypeParameter = 141,
TSTypeParameterDeclaration = 142,
TSTypeAliasDeclaration = 143,
TSClassImplements = 144,
TSInterfaceDeclaration = 145,
TSPropertySignature = 146,
TSCallSignatureDeclaration = 147,
TSMethodSignature = 148,
TSConstructSignatureDeclaration = 149,
TSIndexSignatureName = 150,
TSInterfaceHeritage = 151,
TSTypePredicate = 152,
TSModuleDeclaration = 153,
TSModuleBlock = 154,
TSTypeLiteral = 155,
TSInferType = 156,
TSTypeQuery = 157,
TSImportType = 158,
TSMappedType = 159,
TSTemplateLiteralType = 160,
TSAsExpression = 161,
TSSatisfiesExpression = 162,
TSTypeAssertion = 163,
TSImportEqualsDeclaration = 164,
TSExternalModuleReference = 165,
TSNonNullExpression = 166,
Decorator = 167,
TSExportAssignment = 168,
TSInstantiationExpression = 169,
JSDocNullableType = 170,
JSDocNonNullableType = 171,
JSDocUnknownType = 172,
TSArrayType = 121,
TSIndexedAccessType = 122,
TSNamedTupleMember = 123,
TSAnyKeyword = 124,
TSStringKeyword = 125,
TSBooleanKeyword = 126,
TSNumberKeyword = 127,
TSNeverKeyword = 128,
TSIntrinsicKeyword = 129,
TSUnknownKeyword = 130,
TSNullKeyword = 131,
TSUndefinedKeyword = 132,
TSVoidKeyword = 133,
TSSymbolKeyword = 134,
TSThisType = 135,
TSObjectKeyword = 136,
TSBigIntKeyword = 137,
TSTypeReference = 138,
TSTypeName = 139,
TSQualifiedName = 140,
TSTypeParameterInstantiation = 141,
TSTypeParameter = 142,
TSTypeParameterDeclaration = 143,
TSTypeAliasDeclaration = 144,
TSClassImplements = 145,
TSInterfaceDeclaration = 146,
TSPropertySignature = 147,
TSCallSignatureDeclaration = 148,
TSMethodSignature = 149,
TSConstructSignatureDeclaration = 150,
TSIndexSignatureName = 151,
TSInterfaceHeritage = 152,
TSTypePredicate = 153,
TSModuleDeclaration = 154,
TSModuleBlock = 155,
TSTypeLiteral = 156,
TSInferType = 157,
TSTypeQuery = 158,
TSImportType = 159,
TSMappedType = 160,
TSTemplateLiteralType = 161,
TSAsExpression = 162,
TSSatisfiesExpression = 163,
TSTypeAssertion = 164,
TSImportEqualsDeclaration = 165,
TSExternalModuleReference = 166,
TSNonNullExpression = 167,
Decorator = 168,
TSExportAssignment = 169,
TSInstantiationExpression = 170,
JSDocNullableType = 171,
JSDocNonNullableType = 172,
JSDocUnknownType = 173,
}

/// Untyped AST Node Kind
Expand Down Expand Up @@ -320,6 +321,7 @@ pub enum AstKind<'a> {
TSUnionType(&'a TSUnionType<'a>) = AstType::TSUnionType as u8,
TSIntersectionType(&'a TSIntersectionType<'a>) = AstType::TSIntersectionType as u8,
TSParenthesizedType(&'a TSParenthesizedType<'a>) = AstType::TSParenthesizedType as u8,
TSArrayType(&'a TSArrayType<'a>) = AstType::TSArrayType as u8,
TSIndexedAccessType(&'a TSIndexedAccessType<'a>) = AstType::TSIndexedAccessType as u8,
TSNamedTupleMember(&'a TSNamedTupleMember<'a>) = AstType::TSNamedTupleMember as u8,
TSAnyKeyword(&'a TSAnyKeyword) = AstType::TSAnyKeyword as u8,
Expand Down Expand Up @@ -517,6 +519,7 @@ impl GetSpan for AstKind<'_> {
Self::TSUnionType(it) => it.span(),
Self::TSIntersectionType(it) => it.span(),
Self::TSParenthesizedType(it) => it.span(),
Self::TSArrayType(it) => it.span(),
Self::TSIndexedAccessType(it) => it.span(),
Self::TSNamedTupleMember(it) => it.span(),
Self::TSAnyKeyword(it) => it.span(),
Expand Down Expand Up @@ -1179,6 +1182,11 @@ impl<'a> AstKind<'a> {
if let Self::TSParenthesizedType(v) = self { Some(v) } else { None }
}

#[inline]
pub fn as_ts_array_type(self) -> Option<&'a TSArrayType<'a>> {
if let Self::TSArrayType(v) = self { Some(v) } else { None }
}

#[inline]
pub fn as_ts_indexed_access_type(self) -> Option<&'a TSIndexedAccessType<'a>> {
if let Self::TSIndexedAccessType(v) = self { Some(v) } else { None }
Expand Down
4 changes: 3 additions & 1 deletion crates/oxc_ast_visit/src/generated/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3339,9 +3339,11 @@ pub mod walk {

#[inline]
pub fn walk_ts_array_type<'a, V: Visit<'a>>(visitor: &mut V, it: &TSArrayType<'a>) {
// No `AstKind` for this type
let kind = AstKind::TSArrayType(visitor.alloc(it));
visitor.enter_node(kind);
visitor.visit_span(&it.span);
visitor.visit_ts_type(&it.element_type);
visitor.leave_node(kind);
}

#[inline]
Expand Down
4 changes: 3 additions & 1 deletion crates/oxc_ast_visit/src/generated/visit_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3506,9 +3506,11 @@ pub mod walk_mut {

#[inline]
pub fn walk_ts_array_type<'a, V: VisitMut<'a>>(visitor: &mut V, it: &mut TSArrayType<'a>) {
// No `AstType` for this type
let kind = AstType::TSArrayType;
visitor.enter_node(kind);
visitor.visit_span(&mut it.span);
visitor.visit_ts_type(&mut it.element_type);
visitor.leave_node(kind);
}

#[inline]
Expand Down
16 changes: 10 additions & 6 deletions crates/oxc_formatter/src/generated/ast_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ pub enum AstNodes<'a> {
TSUnionType(&'a AstNode<'a, TSUnionType<'a>>),
TSIntersectionType(&'a AstNode<'a, TSIntersectionType<'a>>),
TSParenthesizedType(&'a AstNode<'a, TSParenthesizedType<'a>>),
TSArrayType(&'a AstNode<'a, TSArrayType<'a>>),
TSIndexedAccessType(&'a AstNode<'a, TSIndexedAccessType<'a>>),
TSNamedTupleMember(&'a AstNode<'a, TSNamedTupleMember<'a>>),
TSAnyKeyword(&'a AstNode<'a, TSAnyKeyword>),
Expand Down Expand Up @@ -327,6 +328,7 @@ impl<'a> AstNodes<'a> {
Self::TSUnionType(n) => n.span(),
Self::TSIntersectionType(n) => n.span(),
Self::TSParenthesizedType(n) => n.span(),
Self::TSArrayType(n) => n.span(),
Self::TSIndexedAccessType(n) => n.span(),
Self::TSNamedTupleMember(n) => n.span(),
Self::TSAnyKeyword(n) => n.span(),
Expand Down Expand Up @@ -506,6 +508,7 @@ impl<'a> AstNodes<'a> {
Self::TSUnionType(n) => n.parent,
Self::TSIntersectionType(n) => n.parent,
Self::TSParenthesizedType(n) => n.parent,
Self::TSArrayType(n) => n.parent,
Self::TSIndexedAccessType(n) => n.parent,
Self::TSNamedTupleMember(n) => n.parent,
Self::TSAnyKeyword(n) => n.parent,
Expand Down Expand Up @@ -685,6 +688,7 @@ impl<'a> AstNodes<'a> {
Self::TSUnionType(_) => "TSUnionType",
Self::TSIntersectionType(_) => "TSIntersectionType",
Self::TSParenthesizedType(_) => "TSParenthesizedType",
Self::TSArrayType(_) => "TSArrayType",
Self::TSIndexedAccessType(_) => "TSIndexedAccessType",
Self::TSNamedTupleMember(_) => "TSNamedTupleMember",
Self::TSAnyKeyword(_) => "TSAnyKeyword",
Expand Down Expand Up @@ -5667,11 +5671,11 @@ impl<'a> AstNode<'a, TSType<'a>> {
parent,
allocator: self.allocator,
})),
TSType::TSArrayType(s) => {
panic!(
"No kind for current enum variant yet, please see `tasks/ast_tools/src/generators/ast_kind.rs`"
)
}
TSType::TSArrayType(s) => AstNodes::TSArrayType(self.allocator.alloc(AstNode {
inner: s.as_ref(),
parent,
allocator: self.allocator,
})),
TSType::TSConditionalType(s) => {
AstNodes::TSConditionalType(self.allocator.alloc(AstNode {
inner: s.as_ref(),
Expand Down Expand Up @@ -5938,7 +5942,7 @@ impl<'a> AstNode<'a, TSArrayType<'a>> {
self.allocator.alloc(AstNode {
inner: &self.inner.element_type,
allocator: self.allocator,
parent: self.parent,
parent: self.allocator.alloc(AstNodes::TSArrayType(transmute_self(self))),
})
}
}
Expand Down
5 changes: 4 additions & 1 deletion crates/oxc_formatter/src/generated/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,10 @@ impl<'a> Format<'a> for AstNode<'a, TSTypeOperator<'a>> {

impl<'a> Format<'a> for AstNode<'a, TSArrayType<'a>> {
fn fmt(&self, f: &mut Formatter<'_, 'a>) -> FormatResult<()> {
self.write(f)
format_leading_comments(self.span().start).fmt(f)?;
let result = self.write(f);
format_trailing_comments(self.span().end).fmt(f)?;
result
}
}

Expand Down
3 changes: 3 additions & 0 deletions crates/oxc_linter/src/rules/typescript/array_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ impl Rule for ArrayType {
&self.readonly.clone().unwrap_or_else(|| default_config.clone());

match node.kind() {
AstKind::TSArrayType(ts_array_type) => {
check(&ts_array_type.element_type, default_config, readonly_config, ctx);
}
AstKind::TSTypeAnnotation(ts_type_annotation) => {
check(&ts_type_annotation.type_annotation, default_config, readonly_config, ctx);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/type-annotation
"flags": "ReferenceFlags(Type)",
"id": 0,
"name": "T",
"node_id": 13
"node_id": 14
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/type-declaratio
"flags": "ReferenceFlags(Type)",
"id": 0,
"name": "A",
"node_id": 14
"node_id": 15
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/type-declaratio
"flags": "ReferenceFlags(Type)",
"id": 0,
"name": "A",
"node_id": 13
"node_id": 14
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ input_file: crates/oxc_semantic/tests/fixtures/typescript-eslint/type-declaratio
"flags": "ReferenceFlags(Type)",
"id": 0,
"name": "T",
"node_id": 11
"node_id": 12
}
]
},
Expand Down
1 change: 0 additions & 1 deletion tasks/ast_tools/src/generators/ast_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const STRUCTS_BLACK_LIST: &[&str] = &[
"AccessorProperty",
"ImportAttribute",
"TSTypeOperator",
"TSArrayType",
"TSTupleType",
"TSOptionalType",
"TSRestType",
Expand Down
Loading