Or at the very least, library documentation really needs to clearly specify the types of parameters and return values. I'm positively surprised when I come across a JavaScript API whose documentation actually specifies this very basic information. Coming from the static typing world, it's astounding...
Yes. And, having worked with typescript, its quite annoying how poor most typings files are that you get from the definitelytyped repository. It's better than nothing, but they are unversioned (so always behind) and often very incomplete. I agree with the author: types are there anyway, typescript seems to work well enough and has traction now, so please, if you write a library: add those type annotations bottom-up i…
JavaScript libraries should be written in TypeScript
51–60 of 285 posts
Re: JavaScript libraries should be written in TypeScript
#52Starts off with: > Typed vs dynamic is a rather controversial topic, so I’m not trying to spark that discussion all over again. Goes on to explain that typed is betterer... The article doesn't really offer up any real arguments as to why you should specifically use TypeScript, but really just says typed is nice and everyone lints anyway (not true) so the step up to a type system really isn't that big of a deal (also…
Context matters. Some people, while writing their own application code , find types to be annoying, a nuisance, or whatever. That's a personal (or team) decision. This article is targeted at authors and maintainers of high-adoption libraries. It says so right in the second paragraph. And, frankly (speaking as someone with experience on this topic), he's right. Maybe static isn't always the answer, but in the context…
Re: JavaScript libraries should be written in TypeScript
#53I just hope this will not be yet another point of fragmentation for JavaScript. Not looking forward to not only having to use different build tools for all libraries I work with but also different pre-processors and type analyzers. Oh my.
Re: JavaScript libraries should be written in TypeScript
#54Re: JavaScript libraries should be written in TypeScript
#55The alternative to that of course is Babel. Which is standard JavaScript, mostly. Including the draft stuff that isn't ratified yet. But you don't have to use any of that if you don't want. And things like Flow and JSX, which are just plugins so again, you can take them or leave them.
The authors argument eventually distills down to a choice between TypeScript and Flow. He concludes that TS is the best choice because it has the momentum, but that's a false choice. The choice is between Microsoft's TypeScript transpiler and Babel.
If you use Babel you can choose to use Flow, but if you use TypeScript you lose out on everything else Babel has to offer.
And outside of the .Net+Angular world, Babel has all the momentum.
Re: JavaScript libraries should be written in TypeScript
#56TypeScript doesn't solve the problem at all. It merely adds another layer of complexity/knowledge to a Library that still compiles to JavaScript. Write it in JavaScript, deliver it in JavaScript. If your documentation and implicit typesetting is giving you pains, then you should revisit what you have written and how you've built your library. Not switch to something that tries to enforce better behaviour.
Re: JavaScript libraries should be written in TypeScript
#57Absolutely not. This is the opposite of what you should do in my opinion. If you're writing an API to be consumed in language X then you need to write the API itself in language X. This will help you capture and handle edge cases, language idiosyncrasies and other similar issues the way you want. Using a different language that gets transpiled into a target language also increases your surface area for bugs because n…
Re: JavaScript libraries should be written in TypeScript
#58I still run into libraries written in Coffeescript, and hate it when I do, because I don't use it and have a hard time following it. Javascript libraries should be written in Javascript. Worship the one true God!
Except this really isn't an issue for TypeScript, it reads that close to JavaScript.
Re: JavaScript libraries should be written in TypeScript
#59Earlier quoted context omitted.
What's a "big" JavaScript library? How do you know how widely adopted your JavaScript library will be?
Regardless, it's difficult to think of any situation where a All _______ should use _______ is really justified.
Re: JavaScript libraries should be written in TypeScript
#60Earlier quoted context omitted.
Except this really isn't an issue for TypeScript, it reads that close to JavaScript.
Maybe we'll agree to disagree but this [0] doesn't read very close to Javascript at all. [0] https://github.com/Microsoft/TypeScriptSamples/blob/master/t...