jaysylvester / citizen

Node.js MVC web application framework. Includes routing, serving, caching, session management, and other helpful tools.
MIT License
100 stars 7 forks source link

TypeScript support #131

Open jaysylvester opened 3 days ago

jaysylvester commented 3 days ago

See title.

Dimava commented 3 days ago

I'm interested in trying to try to implement this Mostly to see how the "old-school app servers" worked

With --experimental-strip-types node doesn't even need anything else to run TS

I'll make a draft PR tomorrow so you're able to see how typescript changes this codebase

I've looked up the code It uses a lot of ||, are they actually intended to be || or they are intended to be ?? (as || also applies to false so you can't disable stuff on case by case basis) In some cases there are foo || bar ? a : b which gets parsed as (foo || bar) ? a : b, please add brackets there

jaysylvester commented 3 days ago

The || logic is all correct (no bugs or unexpected behavior as far as I know), but there are probably suboptimal examples (or perhaps code others consider problematic that I don't find objectionable) I've avoided touching because they currently work as expected.

Are you looking to make it compatible with apps written in TS or changing citizen itself to be written in TS?

Dimava commented 3 days ago

I'm "rewriting" it to node-compatible TS (basically just adding variable types) Then it can compiled back to JS with something like https://bloomberg.github.io/ts-blank-space/ + d.ts if needed

Rewriting + compiling to d.ts is somewhat easier then just adding d.ts as it immediately errors if types don't match