Hacker News

GitGitGadget

Hacker News - Wed, 09/18/2024 - 3:58am

Article URL: https://gitgitgadget.github.io

Comments URL: https://news.ycombinator.com/item?id=41577027

Points: 1

# Comments: 0

Categories: Hacker News

What Is React.js?

Hacker News - Wed, 09/18/2024 - 3:57am
Categories: Hacker News

Wetting Current

Hacker News - Wed, 09/18/2024 - 3:50am
Categories: Hacker News

Show HN: TestTrove: Portal for taking tests and publishing tests/quizzes

Hacker News - Wed, 09/18/2024 - 3:49am

Nothing fancy. Just a simple portal to allow users to freely publish and take tests. Free publishing and no premium feature non sense. It does not have many features right now, but appreciate any feedback and/or criticisms.

Comments URL: https://news.ycombinator.com/item?id=41576957

Points: 1

# Comments: 0

Categories: Hacker News

Show HN: Parse your Postgres queries into a fully-typed AST in TypeScript

Hacker News - Wed, 09/18/2024 - 3:49am

Hey all, I'm the creator of @pg-nano/pg-parser. I'm using it in pg-nano[1] to statically analyze Postgres schemas spread across multiple SQL files for a couple of reasons:

1. Each CREATE statement needs to be in topological order, so pg-nano's dev command can execute them without issue.

2. pg-nano has a plugin system like Vite that allows SQL generation based on the parsed schema.

Probably to the surprise of no one, working with an untyped AST feels like you're back in the days of JavaScript, because well... you are. Most of you know by now just how great TypeScript and static types in general are, especially if you appreciate SQL.

So why is this project worth sharing with you?

Well, writing the AST type definitions by hand would have taken me way too much time. It would also be a bear to keep up-to-date as Postgres continues to evolve.

To my surprise, I discovered that libpg_query, the C library used under-the-hood, includes JSON definitions in their /srcdata/ folder. I figured I could use them to generate the type definitions. Genius, right? Okay... maybe not genius, but still cool, I think.

You see, those JSON definitions provided by libpg_query? They don't exactly contain the TypeScript definitions (was that obvious?). No, no. I had to translate them into TypeScript definitions. (I'm sure you could have done it, yes yes. But did you? No siree bob)

It was pain-staking, but overall really not too hard. Time-consuming? Yes, but not as much as writing the type definitions by hand. So... was it worth it? Only time will tell. I hope you find it as useful as I do. And that's all I've got, so thanks for reading.

P.S. The build for Windows is broken, so if anyone could lend a hand, you would be a true hero.

[1]: https://github.com/pg-nano/pg-nano (not ready for production use)

Comments URL: https://news.ycombinator.com/item?id=41576956

Points: 2

# Comments: 0

Categories: Hacker News

Power Law of Practice

Hacker News - Wed, 09/18/2024 - 3:10am
Categories: Hacker News

Hick's Law

Hacker News - Wed, 09/18/2024 - 3:08am
Categories: Hacker News

TopExpert: Find the best expert for your needs

Hacker News - Wed, 09/18/2024 - 2:52am

Article URL: https://www.topexpert.online

Comments URL: https://news.ycombinator.com/item?id=41576599

Points: 1

# Comments: 1

Categories: Hacker News

Pages