3 ms·
I haven't used TypeScript yet, but it seems like it's similar to a pattern I sometimes use, like the following: function foo(a, b, c) { g.param(String, a)
by tabeth 10y ago
I haven't used TypeScript yet, but it seems like it's similar to a pattern I sometimes use, like the following:
function foo(a, b, c) {
g.param(String, a);
g.param(Object, b);
g.param(XMLHttpRequest, c);
/* stuff */
g.return(String, bar);
}
Seems like the main benefit to using TypeScript is that it can tell you if you have poor types during "compile" time, right?
I guess the question for me is, is TypeScript superior than the above pattern?
- chillacy 10y agoAutocomplete is a big productivity boost too: VS Code will suggest methods on the object, then tell you exactly what arguments it takes and what types they all are. Of course maybe you can have another system which reads in the code you have and autocompletes for you too.. after all, the type info is all there, it's just in a different place. Compared to everything in the function definition: function foo(a: string, b: object, c: XMLHttpRequest): string
- to3m 10y agoYes, because it will check for you before you run the code, and you can be certain as you can be about anything that no case was missed.