diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index 6e53b6a7d73bf..66216b6dcc5c4 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -53,6 +53,22 @@ pub fn traverse<'a, T: Traverse<'a>>( // walk_traversable_program(traverser, program, ctx, tk); } +// TODO: Delete this - just for testing type layouts. +// The `inherit_variants!` macro has screwed up `layout_inspect` - it can't see these inherited types. +#[derive(layout_inspect::Inspect)] +pub enum FakeForTestingInheritedTypes<'a> { + Program(Box<'a, Program<'a>>), + MemberExpression(Box<'a, MemberExpression<'a>>), + Expression(Box<'a, Expression<'a>>), + SimpleAssignmentTarget(Box<'a, SimpleAssignmentTarget<'a>>), + AssignmentTargetPattern(Box<'a, AssignmentTargetPattern<'a>>), + AssignmentTarget(Box<'a, AssignmentTarget<'a>>), + Declaration(Box<'a, Declaration<'a>>), + ModuleDeclaration(Box<'a, ModuleDeclaration<'a>>), + TSType(Box<'a, TSTypeName<'a>>), + TSTypeName(Box<'a, TSTypeName<'a>>), +} + #[ast_node] #[derive(Debug, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize, Tsify))] diff --git a/tasks/inspect_ast/lib/index.mjs b/tasks/inspect_ast/lib/index.mjs index 1a3a3b4849b46..2588ced821a4a 100644 --- a/tasks/inspect_ast/lib/index.mjs +++ b/tasks/inspect_ast/lib/index.mjs @@ -102,6 +102,7 @@ console.log('--------------------'); console.log('> Nested enums:'); const nestedEnums = Object.values(types).flatMap((type) => { if (type.kind !== 'enum') return []; + if (type.name === 'FakeForTestingInheritedTypes') return []; return type.variants.filter(({type: variantType}) => ( variantType?.kind === 'enum' || (variantType?.kind === 'box' && variantType.value.kind === 'enum') diff --git a/tasks/inspect_ast/src/main.rs b/tasks/inspect_ast/src/main.rs index 38b2f41e7a91b..587f397fd7b4b 100644 --- a/tasks/inspect_ast/src/main.rs +++ b/tasks/inspect_ast/src/main.rs @@ -2,10 +2,10 @@ use layout_inspect::inspect; -use oxc_ast::ast::Program; +use oxc_ast::ast::FakeForTestingInheritedTypes; pub fn main() { - let types = inspect::(); + let types = inspect::(); let json = serde_json::to_string_pretty(&types).unwrap(); println!("{json}"); }