Hacker News new | ask | show | jobs
by cfontes 3896 days ago
I've been playing around with typescript and together with IntelliJ it's just great... Fast transpiling, easy to config, easy to debug, typed, the list goes on...

The only thing that toke me a while to understand at the start was the whole "Definetly Typed" repo, why and how to use it. It is a bit strange to have to add types as you develop but you can live with it after it sits in.

There is also Angular 2 which mergers very well with it, friendly advice, try it!

3 comments

I hope this new feature https://github.com/Microsoft/TypeScript/wiki/Typings-for-npm... means that little by little the type definitions will move to the projects themselves rather than having all of them together in a single repo.
Yes, DefinitelyTyped has gotten huge and it would be great to at least see npm packages own typing definitions for themselves. Unfortunately, there will still be plenty of npm package maintainers that won't care for Typescript definitions in their repositories and I still think there probably needs to be a more distributed type definition package management option than DefinitelyTyped. (I don't know what that would look like just yet, otherwise I'd probably have tried to build it.)
Absolutely needed. While the Definitely Typed project is a commendable effort, the definitions themselves are often incomplete and out of date, which is problematic because, at least in my mind, an out of date type definition is worse than having no definition at all.

The problem core of the problem is that many of the definitions they host are contributed as one-offs by developers who create them as needed, and often there is no one responsible for making sure they get updated in lock step with the library itself.

The only way I can think to solve this is to have a contributor to the library itself be responsible for maintaining its type definition, so that keeping it up to date becomes part of the release process. Of course, really everyone should just switch development to typescript so that the defs get generated automatically ;)

I hope you are right!
My experience with Typescript is that I have spent the majority of what I would call 'wasted' time either messing with type definitions, or fumbling with getting modules to play nicely with code that needs to be used in the browser and in Node. My impression of the language is fairly positive, however I'm not currently using it for backend development because the burden of the type definition files is too great. Having to write a type definition file yourself for a library where none exists has been fairly painful in my experience.
If you don't have time to write a type definition file, there's always the fallback to any type. (I tend to start with any-typed things, see any as a TODO marker, and then fill in definitions as I have time, interest, or need.)

declare var SomeGlobal: any

declare module 'some-node-module' { declare var m: any; export = m }

Also, hopefully more npm package maintainers will start to add typings directly now that TypeScript searches node_modules.

Given the amount of debugging you'd save using a library that's untyped I wouldn't call it time wasted.

If a definition doesn't match the version of library you're using, changing the definition or adding to it omly takes a few minutes.

I haven't tried to use it for backend either, but I've used it for developing safari extensions, for which no typings exist, and I'm a little surprised about your comments wrt adding types being painful.

It has seemed pretty easy to add types for the parts of the library I need, rather than the entire library. Is there anything in particular that makes partially typing server-side libraries difficult?

This is one of the main reasons why we stopped using Typescript (a couple of years ago). I spend most of the time fixing type definitions on DefinitelyTyped
being cheap I tested the pipeline with eclipse and groovy, with nice results https://www.thinkingonsoftware.net/tech/eclipse-ide-configur...

minus a couple of bugs which should be fixed by now.

I was to build the startup front-end with typescript, but then there were too many libraries needing manual wrapping and I didn't want to experiment too much.