Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【question】Is ast-types not compatible with estree? #953

Open
alamhubb opened this issue Nov 18, 2024 · 1 comment
Open

【question】Is ast-types not compatible with estree? #953

alamhubb opened this issue Nov 18, 2024 · 1 comment

Comments

@alamhubb
Copy link

alamhubb commented Nov 18, 2024

Hello, I now have a custom extended estreeAst, which extends some custom ast types. I need to convert the extended ast to the estree standard ast. I am looking for an open source library that can achieve this function. I learned about ast-types,

builders.stringLiteral

But I found that there is no stringLiteral in estreeAst, but Literals that are uniformly used for stringLiteral, numberLiteral, etc.

Also

estree2022

extend interface ClassBody {
    body: [ MethodDefinition | PropertyDefinition | StaticBlock ];
}

ast-types

interface ClassBody extends Omit<Declaration, "type"> {
        type: "ClassBody";
        body: (K.MethodDefinitionKind | K.VariableDeclaratorKind | K.ClassPropertyDefinitionKind | K.ClassPropertyKind | K.ClassPrivatePropertyKind | K.ClassAccessorPropertyKind | K.ClassMethodKind | K.ClassPrivateMethodKind | K.StaticBlockKind | K.TSDeclareMethodKind | K.TSCallSignatureDeclarationKind | K.TSConstructSignatureDeclarationKind | K.TSIndexSignatureKind | K.TSMethodSignatureKind | K.TSPropertySignatureKind)[];
    }

I found that the node names in ast-types are inconsistent with those in estree, so I am a little confused. I hope to get your reply. Thank you.

I apologize if I disturbed you.

@alamhubb
Copy link
Author

Hello, I think I understand the correct meaning of compatible in ast-types. It can process estree standard AST, but it does not mean that the generated AST is estree standard AST.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant