DEV Community

SieR
SieR

Posted on

2

Stop Using "AST" Directly

This is my first post on dev.to! Hello everyone!

Hello!

I'm making tool for typescript transform named "transformer-query", which can query typescript AST and able to change its structure more intuitively. Despite it is still developing, I wanted to share my concept.

Why not "AST"?

As with any programming language, ASTs are complex. The AST corresponds to the grammar, but has additional information. That's why interacting with the AST was complicated. Typescript wasn't exception.

What is "transformer-query"?

Here's repository: transformer-query (still no readme, complicated code)

It provides more intuitive way for interacting with ASTs.
Thanks for ttypescript, this made it easy to develop this library.

How to use

Image description

makeTransform() returns ttypescript transform function. So, we can use like that.

Query should be tagged string literal. And it accepts imported variable or interal wildcard.

And call chain, which appears next of query, can return valid typescript code or ts.Node interface.

That's it! after this, just register it with the method described on ttypescript.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more