Live data from Hacker News

JavaScript libraries should be written in TypeScript

staltz.com

71–80 of 285 posts

Re: JavaScript libraries should be written in TypeScript

#71
post #23

Earlier quoted context omitted.

Except this really isn't an issue for TypeScript, it reads that close to JavaScript.

It's not about reading, it's about the tooling you need to set it up. JS initial strengh was ease of dev for beginers. Throw in a transpiler, a dependancy manager, a package manager, a bundler with FS watching, and source maps and what you got is wall for the very same type of dev that were producing all those fantastic jQuery plugins 10 years ago. And actually even for me. I do know how to install and use all those.…

> It's not about reading, it's about the tooling you need to set it up.

npm install typescript -g

This is the only addition on top of vanilla js, which is what you should be comparing with instead of the massive crap of build-tool-of-the-month. All said and done, if you're using those build tools in typescript, you'd be using them for javascript as well.

Re: JavaScript libraries should be written in TypeScript

#72

I'm not certain I agree. I agree with better type systems, but does anyone remember ECMAScript 4? Which Microsoft vetoed after Macromedia had gone ahead and adopted it as ActionScript 3 (coincidentally around the time they were trying to get everyone to adopt Silverlight). Well that's basically what TypeScript is (with slightly more advanced type support). It's a nonstandard dialect of JavaScript. Something that ever…

What does one miss out from Babel, given that TS is a superset of ES6?

Re: JavaScript libraries should be written in TypeScript

#74
post #63

Absolutely 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…

This reads like knee-jerk reaction from someone who's never tried TypeScript.

Criticism of that statement kind of hinges on the source material being solid enough to be taken seriously.

I mean, one of his main points is that everything written in JS should be written in typescript because it helps support typescript users. Another it is leads to better documentation, with no qualification of how that happens. It might make your intent more explicit to a reader of the source code, but that doesn't magically translate into documentation for an API user.

I personally find nothing good about trying to coercing a language into something it isn't and then transpilling it back and that article has no strong argument to make me feel any different.

Re: JavaScript libraries should be written in TypeScript

#75

Absolutely 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…

APIs written in C seem to do just fine.

Re: JavaScript libraries should be written in TypeScript

#77

All x should be y is a bad statement to make, especially if you are an engineering. Every problem domain is different. And every choice has pros and cons.

This. Qualifying with "All" rejects all the cases where the statement might not be true for unforeseen reasons. Disclaimer: I generally agree with the OP despite the presumptive title.

Re: JavaScript libraries should be written in TypeScript

#78

Exact same arguments that I use when arguing that any software above a certain complexity level and intended for a long life and maintenance should be written in a strongly typed language with working generics system. Seems ironic that JS community is starting to come around to that finally.

It's more like a vocal minority rather then the "JS community". Apart from Angular && .NET people, Babel has the momentum.

Re: JavaScript libraries should be written in TypeScript

#79
People make basic mistakes routinely with types. Even with very sophisticated type systems, like the one used in Haskel. There's evidence that in rare cases where people could have been "helped" by a type system, the cost of finding and fixing such a bug is far lower than using a type system to enforce correctness in the first place. You will write automated tests whether you're using a type system or not.

Re: JavaScript libraries should be written in TypeScript

#80
I was kind of frustrated for a while with the broken type system of Javascript, as well as with the lack of easy type checking. I then wrote a simple small library to make my life a little easier. It's called types.js, in NPM as well..

Changing my entire code to TypeScript just feels a bit over the top to achieve only static type checking. I now only dynamically check if needed. I believe there are so much worse and important problems we are dealing with as Javascript developers today that need attention.

I really believe WASM will become the base for a great new language that eventually will make Javascript, TypeScript and so many others deprecated, solving a zillion problems at once.

Post reply on HN