Hacker News new | ask | show | jobs
by tigeba 3898 days ago
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.
4 comments

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