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.Edit: especially pertaining to type inference, I guess?
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.
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.
My personal projects are more rigorous than my work projects. I don't have time to maintain them, so I have to be sure to not fuck them up.
But in a smaller shop, oncall are developers, that is, ourselves.
Personally I also find coming up with the correct types to be gratifying if they’re a little tricky.
“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.
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.