benjamn / benjamn/ast-types

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

Open
#953 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.2k
Forks
194
Avg merge
22h 43m
Merged PRs (30d)
10

Description

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 {
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.

Contributor guide

No contributing guide indexed for this repository

Research direction

No source files or tests are named. Start by comparing the `builders.stringLiteral` entry point and the ast-types declarations with the estree2022 `ClassBody` definition shown in the issue. Done would be a documented compatibility answer or a clearly scoped conversion proposal.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
compilers, devtools
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.