Hacker News new | ask | show | jobs
by dec0dedab0de 1198 days ago
So he wrote all that for the typescript lsp to respond with the answer, but when it compiles down it's nothing? And we're using runes as variables just because?

That is pretty neat, and silly.

I also think it highlights my natural aversion to static type checking in dynamic languages. I know that I could get sucked into writing a bunch of code for the checker, instead of using my energy for making the application work.

4 comments

The runes are mostly "just because", but there is a reason.

Ideally, I would have written:

  type Nil = unique symbol
Which would ensure the Nil type wouldn't match with anything but itself. Unfortunately, the compiler doesn't allow unique symbol other than on const variables initialised with Symbol(). So I needed some meaningless symbols.

I could also have done

  type Nil = "nil"
But then it would have looked like the string meant something.
> I know that I could get sucked into writing a bunch of code for the checker, instead of using my energy for making the application work.

“Making the application work” is only half the story. Making a large application stable and maintainable is only really possible with static type safety, IMHO.

brilliant article - the TS therein is type-hints basically, helping the coder program to chess spec. so yes, in that scenario it's not generating JS (functions etc) lol
this is why i love ts when not working for a megacorp. when the ts gets too cray i just nope out. throw an any or as in there and get on with my day. wouldn't pass a code review but i don't care
IMHO it’s worth learning to properly type those cases, otherwise you never really know which parts of your application are actually being type checked.

Personally I also find coming up with the correct types to be gratifying if they’re a little tricky.

In a megacorp, an SRE in production would have to deal with a rare error condition which the compiler tried to complain about.

But in a smaller shop, oncall are developers, that is, ourselves.