Re:TypeScript at Google
by Karupan on Saturday September 01, 2018 @10:16PM
(#17895139)
I love typescript as a JavaScript developer, but having used go for personal projects, I find the type system complex (maybe necessarily so). Having said that, I cannot thank TS enough for how it’s made life easier when working on and refactoring large codebases.
[ Parent
| on HN ]
I don't know what you find complex about the type system, but I actually find it slightly limiting. They keep improving it, so it can express about 95% of what I want, but I still hit situations where I can't tell the compiler everything.
Re:TypeScript at Google
by MuppetMaster42 on Sunday September 02, 2018 @12:53AM
(#17895622)
I'm the same. Anything I do, I make sure it's in typescript because I find it easier to write than standard js.
Generics are a complex concept for people to grasp without some time playing and reading docs, but once you learn it, you can express almost everything you want.
But for simple projects you can get away with all but the most basic of generics, if any at all.
With the release of conditional types, I find most of my js typing cases are covered.
Though tbh I've always leant toward the side of "if you can't express it easily, then you're being to JavaScripty".
My comment was in the context of having used Golang. It maybe a personal experience as I primarily come from dynamic, weakly typed languages, and TypeScript and Golang are my first serious foray into typed languages.
What sorts of things do you have trouble expressing with the type system?
I can't think of something off the top of my head, but it's usually related to generics. I'll type something that makes sense, but the compiler doesn't like it.
Another issue is that handling of string literals as types can be wonky when they're being compared against the type "string", which they should always satisfy but sometimes don't.
I’d love to see examples for those, maybe drop a comment when you run across a specific issue.