Hacker News new | ask | show | jobs
by radicalbyte 4467 days ago
We've been using TypeScript for 9 months now on a large project. It's fantastic. There's now way I'll go back to pure JavaScript again.

The type system just catches so many defects, and they're of the kind that are hard and boring to find (typos).

Plus IntelliSense integration (including jsdoc) is great.

On the downside, our project takes some time to compile so we had to build a tool to do it incrementally. Plus it doesn't play well with one-class-per-file structures (but I expect that to be fixed).

4 comments

Agreed, TypeScript is great, but the compiler is excruciatingly slow. I have to segment my app into multiple sub-build areas and only build a subset at a time, which is annoying because I frequently end up making small changes outside of that subset of code. My app is only around 25000 lines of code and a full compilation still takes around 50-60 seconds which, in a JavaScript workflow, is a lot of friction.
I was expecting something in the order of minutes. Seeing as I work at a place where full build used to took about three hours on a server. I see how it's not ideal though.
In a typical Javascript workflow, near-instant feedback is the baseline.

I really like how Facebook's Hack has a local file system monitor which incrementally compiles on file changes. I haven't used it yet, but it sounds like a nearly ideal compromise.

Typescript has a command line option for this as well.

As far as I can tell, the language would also support a non-validating mode that would be more or less instantaneous (the transformations it performs are all local, and none of them involve knowledge of the types involved).

Neat, I'll need to look into that.
I've never actually used TypeScript until today, but just the tutorial code takes forever to compile, this snippet took 2 seconds for example, whaaat??

    interface Person {
        firstname: string;
        lastname: string;
    }

    function greeter(person: Person) {
        return 'Hello, ' + person.firstname + ' ' + person.lastname;
    }

    var user = {firstname: 'John', lastname: 'Doe'}

    document.body.innerHTML = greeter(user);
It's a shame really, because it looks like a really cool project.
It seems there is a minimum time of 2 seconsd to compile anything because even a simple console.log('Hello'); one-liner also takes 2 seconds.
Agreed, TypeScript is great, but the compiler is excruciatingly slow.

This. at least the js one. Maybe VS is bundled with a Typescript compiler written in C# , i dont know,but clearly the javascript one is damn slow.

Visual Studio uses the same compiler written in TypeScript/JavaScript. The Visual Studio integration is done in C# but only for interop with the Visual Studio APIs, there is only one version of the TypeScript compiler.

I know when Palantir was developing Eclipse tools for TypeScript they posted to the Codeplex project regarding performance issues and the team from MS responded with suggestions about caching and only recompiling the minimal targets necessary.

Strange, I'm able to compile 12k lines of code (that's output) in 5.2 seconds. Running this on a watch + autoreload process, so 6 seconds after I hit save, the results show up in my web browser. I do remember 0.9.1 being excruciatingly slow though. Edit: forgot to mention, I'm using the NPM package
It takes under 5 seconds for me to compile my project of about 5000 lines. So it's not really a problem for me yet, though I agree it would be if the waitingtime where to become any longer. Besides that, I've also been really enjoying developing in Typescript!
Same here for a project three times this size. Still I find it extremely slow compared to CoffeeScript I was using before. I'm used to saving the file and instantly refreshing the browser/rebooting node.js.
Typos account for a significant amount of my javascript debugging. To have both intellisense and compile time checking for this would be a huge time saver.
Alternatively, make less typos. Get something basic set up like jshint in your editor of choice (will warn for unused and undeclared variables), that kinda thing.

Although it's more of a patch. A proper IDE for JS would be neat, but it'd need to support popular DI frameworks and the like.

Can you give an example of a defect that the type system catched? You said typos but that's something JSLint would catch as well so not sure if it's a strong argument.
This talk is about porting a AngularJS app to Typescript, and the kind of errors it catches just by adding type definitions: https://www.youtube.com/watch?v=u6TeBM_SC8w

I've not yet ported my Angular apps to Typescript but I'm very much itching to do so.

Officially we were using jshint.

Misspelled magic strings, which were replaced with enumerations.

We also had a number of bugs with unexpected type use - like a function which expected a boolean but was given a string, or even more common number/string failures.

How recognizable is the code when debugging run-time defects in a browser console?
It is very close. If you used lambda expressions they will be replaced with function syntax and _this references, but other than that it is almost the same.