4 ms·
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?
by dec0dedab0de 4y 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.
- ycitm 4y agoThe 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.
- 8n4vidtmkvmk 4y agothis 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
- trhr 4y ago[flagged]
- 8n4vidtmkvmk 4y agonone? is this a jab?
- rexpop 4y agoThis is a jab (insult), and I've flagged it, but I am also curious. If you could, please describe the qualities of a "bootcamp" grad by which you recognize them? Edit: especially pertaining to type inference, I guess?
- trhr 4y agoIf you wanted to have a conversation, you wouldn't have flagged it. So, no.
- jholman 4y agoI didn't flag it, and I'm curious too.
- trhr 4y agoPeople who think code reviews are a thing imposed upon them by higher ups trying to make their job harder and not things designed to make their job easier don't understand how dev works at scale. People who would do things that "wouldn't pass the code review" for smaller companies are a primary reason so many smaller companies get hard-fucked when they have to scale. Arbitrarily deciding "this is too much work for me to do, so I'm going to take a shortcut" may not be the sign of a bootcamper, but it's certainly the sign of a shitty dev. Either way, it's not someone I'll ever work next to. Elite teams don't hire people who think like that. We hire junior devs who are like "I write idempotent commits with good titles and descriptions, and I and use strict typing everywhere." Because it's easier to be teach them "actually, nobody's ever going to read your description. You can usually leave it out. You could use 'any' here. Just ticket it to be fixed so you can replace it later." Point is 'any' shouldn't pass a code review without someone asking "why'd you use 'any' here." If you have a great answer, it will pass the code review.
- jholman 4y agoI'm having trouble grasping what this has to do with bootcamps. Isn't that the totality of the value of your original comment, implying that you had some trick for identifying bootcamp graduates?
- 8n4vidtmkvmk 4y agoFWIW I do both. I work for a top tier tech company and I write pretty commit messages, test my code, and all that jazz. But for the side-project I do at home? You bet I'm cutting corners. I also think the guts of a TS function don't matter much though. Write a test to confirm the behavior is correct, and then make the return type and argument types correct so that people can call it without hassle. If you need to use 'any' or 'as' inside the function, then go for it.
- nine_k 4y agoIn 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.
- tlrobinson 4y agoIMHO 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.
- al_be_back 4y agobrilliant 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
- tlrobinson 4y ago> 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.