frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Experiment: Making TypeScript Immutable-by-Default

https://evanhahn.com/typescript-immutability-experiment/
29•ingve•1h ago

Comments

jbreckmckye•1h ago
> If you figure out how to do this completely, please contact me—I must know!

I think you want to use a TypeScript compiler extension / ts-patch

This is a bit difficult as it's not very well documented, but take a look at the examples in https://github.com/nonara/ts-patch

Essentially, you add a preprocessing stage to the compiler that can either enforce rules or alter the code

It could quietly transform all object like types into having read-only semantics. This would then make any mutation error out, with a message like you were attempting to violate field properties.

You would need to decide what to do about Proxies though. Maybe you just tolerate that as an escape hatch (like eval or calling plain JS)

Could be a fun project!

voidUpdate•46m ago
How do immutable variables work with something like a for loop?
foxygen•44m ago
You use something else like map/filter/reduce or recursion.
tgv•36m ago
Unless you need the index, you can write: for (const x of iterable) { ... } or for (const attribute in keyValueMap) { ... }. However, loops often change state, so it's probably not the way to go if you can't change any variable.
tantalor•24m ago
Is TFA (or anyone else for that matter) actually concerned with "immutable variables"?

e.g., `let i = 0; i++;`

They seem to be only worried about modifying objects, not reassignment of variables.

voidUpdate•18m ago
Looks like Rust is https://doc.rust-lang.org/stable/std/keyword.let.html
macintux•10m ago
Erlang doesn't allow variable reassignment. Elixir apparently does, but I've never played with it.
tyleo•30m ago
This is tangential but one thing that bothers me about C# is that you can declare a `readonly struct` but not a `readonly class`. You can also declare an `in` param to specify a passed-in `struct` can’t be mutated but again there’s nothing for `class`.

It may be beside the point. In my experience, the best developers in corporate environments care about things like this but for the masses it’s mutable code and global state all the way down. Delivering features quickly with poor practices is often easier to reward than late but robust projects.

bilekas•18m ago
I'm not sure if it's what you mean, but can't you have all your properties without a setter, and only init them inside the constructor for example ?

Would your 'readonly' annotation dictate that at compile time ?

eg

class Test {

  private readonly string _testString {get;}


  public Test(string tstSrting) 
      => _testString = tstSrting ;
}

We may be going off topic though. As I understand objects in typescript/js are explicitly mutable as expected to be via the interpertor. But will try and play with it.

phplovesong•15m ago
Sounds easier to just use some other compile to js languge, its not like there are no other options out there.
petejodo•12m ago
Agreed. Gleam is a great one that targets JavaScript and outputs easy to read code
k__•1m ago
I'm still mad about Reason/ReScript for fumbling the bag here.

Cloudflare Global Network experiencing issues

https://www.cloudflarestatus.com/?t=1
1779•imdsm•4h ago•1223 comments

Gemini 3 Pro Preview Live in AI Studio

https://aistudio.google.com/prompts/new_chat?model=gemini-3-pro-preview
72•preek•28m ago•16 comments

Do Not Put Your Site Behind Cloudflare If You Don't Need To

https://huijzer.xyz/posts/123/do-not-put-your-site-behind-cloudflare-if-you-dont
188•huijzer•2h ago•132 comments

Short Little Difficult Books

https://countercraft.substack.com/p/short-little-difficult-books
37•crescit_eundo•1h ago•5 comments

Nearly all UK drivers say headlights are too bright

https://www.bbc.com/news/articles/c1j8ewy1p86o
210•YeGoblynQueenne•1h ago•223 comments

How Quake.exe got its TCP/IP stack

https://fabiensanglard.net/quake_chunnel/index.html
299•billiob•7h ago•46 comments

Experiment: Making TypeScript Immutable-by-Default

https://evanhahn.com/typescript-immutability-experiment/
29•ingve•1h ago•12 comments

The Miracle of Wörgl

https://scf.green/story-of-worgl-and-others/
78•simonebrunozzi•4h ago•41 comments

Ruby 4.0.0 Preview2 Released

https://www.ruby-lang.org/en/news/2025/11/17/ruby-4-0-0-preview2-released/
108•pansa2•2h ago•29 comments

GoSign Desktop RCE flaws affecting users in Italy

https://www.ush.it/2025/11/14/multiple-vulnerabilities-gosign-desktop-remote-code-execution/
39•ascii•3h ago•16 comments

Mathematics and Computation (2019) [pdf]

https://www.math.ias.edu/files/Book-online-Aug0619.pdf
23•nill0•3h ago•3 comments

Gemini 3 Pro Model Card

https://pixeldrain.com/u/hwgaNKeH
322•Topfi•3h ago•217 comments

How many video games include a marriage proposal? At least one

https://32bits.substack.com/p/under-the-microscope-ncaa-basketball
285•bbayles•5d ago•70 comments

Multiple Digital Ocean services down

https://status.digitalocean.com/incidents/lgt5xs2843rx
84•inanothertime•2h ago•29 comments

Show HN: I built a synth for my daughter

https://bitsnpieces.dev/posts/a-synth-for-my-daughter/
1218•random_moonwalk•6d ago•205 comments

The Uselessness of "Fast" and "Slow" in Programming

https://jerf.org/iri/post/2025/the_uselessness_of_fast/
78•zdw•6d ago•44 comments

Ditch your (mut)ex, you deserve better

https://chrispenner.ca/posts/mutexes
105•commandersaki•6d ago•120 comments

Ruby Symbols

https://tech.stonecharioteer.com/posts/2025/ruby-symbols/
55•stonecharioteer•6d ago•35 comments

A/B Tests over Evals

https://www.raindrop.ai/blog/thoughts-on-evals/
12•Nischalj10•4d ago•4 comments

Roma Lister, Aradia, and the Speculative Origins of a Witchcraft Revival

https://publicdomainreview.org/essay/roma-lister-aradia/
8•Vigier•5d ago•0 comments

Azure hit by 15 Tbps DDoS attack using 500k IP addresses

https://www.bleepingcomputer.com/news/microsoft/microsoft-aisuru-botnet-used-500-000-ips-in-15-tb...
430•speckx•21h ago•273 comments

The surprising benefits of giving up

https://nautil.us/the-surprising-benefits-of-giving-up-1248362/
143•jnord•10h ago•117 comments

Langfuse (YC W23) Hiring OSS Support Engineers in Berlin and SF

https://jobs.ashbyhq.com/langfuse/5ff18d4d-9066-4c67-8ecc-ffc0e295fee6
1•clemo_ra•8h ago

When Reverse Proxies Surprise You: Hard Lessons from Operating at Scale

https://www.infoq.com/articles/scaling-reverse-proxies/
79•miggy•5d ago•7 comments

Unofficial "Tier 4" Rust Target for older Windows versions

https://github.com/rust9x/rust
115•kristianp•12h ago•69 comments

My stages of learning to be a socially normal person

https://sashachapin.substack.com/p/my-six-stages-of-learning-to-be-a
552•eatitraw•3d ago•375 comments

Rebecca Heineman has died

https://www.pcgamer.com/gaming-industry/legendary-game-designer-programmer-space-invaders-champio...
751•shdon•14h ago•134 comments

Compiling Ruby to machine language

https://patshaughnessy.net/2025/11/17/compiling-ruby-to-machine-language
271•todsacerdoti•19h ago•49 comments

I've Wanted to Play That 'Killer Shark' Arcade Game Briefly Seen in 'Jaws'

https://www.remindmagazine.com/article/15694/jaws-arcade-video-game-killer-shark-atari-sega-elect...
4•speckx•3d ago•3 comments

Astrophotographer snaps skydiver falling in front of the sun

https://www.iflscience.com/the-fall-of-icarus-you-have-never-seen-an-astrophotography-picture-lik...
437•doener•2d ago•85 comments