9 ms·
Does anyone here have bad things to say about TypeScript? I haven't used it for any large projects yet (couple toy ones) but seems pretty legit. Based on my an
by koolba 11y ago
Does anyone here have bad things to say about TypeScript?
I haven't used it for any large projects yet (couple toy ones) but seems pretty legit. Based on my anecdata, people who have used it at scale seems to like it.
I can't tell if that's because they're still in the honeymoon phase or if it really is a step forward for the long term.
- akavi 11y agoThe ability to programmatically generate methods/classes can be really powerful and, as far as I can tell, impossible with Typescript (and most statically typed languages). Back in my Backbone + CoffeeScript days, I reimplemented Rails style has_many/belongs_to "class methods" on Backbone.Model, and it was incredibly useful. But would've been doubly so if I could have had it statically checked somehow.
- mordocai 11y agoI don't know if it is possible in any practically used statically typed languages, but I can think of nothing that would prevent you from doing metaprogramming in a statically typed language on a theoretical basis. It might be a bit hard to implement, but I think it should be perfectly possible.
- saosebastiao 11y agoIn terms of Javascript targeting languages, Typescript has been the only one that hasn't made me want to murder a thousand baby seals. The build system is fast and easily understood, the typing makes refactoring so much easier, and in probably its biggest win, I can read a Javascript tutorial and trivially write the same thing in Typescript. As a language, though, it still leaves a lot to be desired. Things like type guards and null annotations are like the methadone to the vastly more addictive pattern matching and options that I can no longer live without, and promises/callbacks are vastly inferior to futures. I would rather use Scala.js or Elm, but the ecosystems pale in comparison and trying to work in what is effectively an abstraction layer (and leaky at that) makes life really difficult. So I stick with Typescript.
- woah 11y agoHave you tried a async/await?
- softawre 11y agoasync/await isn't in TypeScript yet, if that's what you were implying. It will be though (and obviously is part of babel if you choose the right pieces).
- billti 11y agoasync/await has been in TypeScript for a while, but currently depend on generators, so don't down-level to <= ES5 emit (that work is in progress). With the latest Node releases and modern browsers supporting generators today, you can target ES6 and use async/await today if you can target those environments. https://blogs.msdn.microsoft.com/typescript/2015/11/03/what-about-asyncawait/ https://blogs.msdn.microsoft.com/typescript/2015/11/03/what-...
- jdmichal 11y agoTop-level types can be permanently shadowed. For instance, if I name a type "Date" within a namespace, then every file within that namespace or a sub-namespace will no longer be able to access the JavaScript native Date type. This also apparently isn't something they're inclined to fix. [0] The tsconfig.json file does not allow for glob-type inclusion of files, or even inclusion of directories. However, you can exclude entire directories. So if I want to simply compile everything in the "src" directory, my best option is to exclude every other directory. [0] https://github.com/Microsoft/TypeScript/issues/983 https://github.com/Microsoft/TypeScript/issues/983
- emodendroket 11y agoIsn't this kind of inherent to the JS model? I mean I guess you could rewrite the names of types at compilation but that would create other problems
- WorldMaker 11y agoTypescript's job is to add safeties to a lot of the JS footguns, but there are a lot of them if you are not careful, and also, even with a safety in place, some people just want to shoot themselves in the foot.
- jdmichal 11y agoNo, because I'm shadowing the type, not overwriting it. JS doesn't have namespace scoping, and therefore everything has to be explicitly scoped. So if I create `my.awesome.Date`, just `Date` means JavaScript's `Date`, and I have to put `my.awesome.Date` to get the new type. Typescript adds namespaces and scoping rules, so that anything in the `my.awesome` namespace or any namespace below it will see `Date` as `my.awesome.Date`. And there's no way to explicitly reference the global scope, so within those namespaces the new type completely and irrevocably shadows the original JavaScript type. Also in JavaScript, unless I overwrite the original `Date` type, I can always explicitly scope it by saying `window.Date`. But TypeScript doesn't define `Date` within the `window` type, so I can't use that out either.
- 11y ago
- corysama 11y agoThe only complaint I've heard is that TS makes JS feel more like C#. Lots of people would say that's a good thing. But, some people really appreciate the dynamic nature of JS.
- ryan-allen 11y agoIn typescript the types are optional, so if you omit types it'll look very much like ES6. You can mix and match dynamic stuff with Typescript, depending on your compiler options, it'll treat non-typed things as if you were writing regular JS. I always turned on 'do not allow 'any' types' because I wanted everything typed. As far as C#... there are enough minor differences for it to be rather annoying if you have to jump back and forth every second day. C# is vastly more powerful and convenient as a language to Typescript, though. I'd write C# in the browser if it were a de-facto option, and I used to write and love Ruby. C# has all the functional stuff I doted over in Ruby, and it's all typesafe!
- WorldMaker 11y agoFurthermore you can give Typescript the allowJS: true compiler option in recent versions and literally mix and match pure JS files and Typescript files in the same "project".
- lmm 11y agoStructural is worse than nominal. The types are unsound even without "any" because arrays are bivariant. There are no HKTs.
- spion 11y agoStructural is not worse than nominal. Nominal types are mostly a lie, and in the case of JS and package managers / module systems like npm / node's, they are a non-starter. Arrays are no longer bivariant, and haven't been for at least a year. They are still covariant unfortunately.
- ryan-allen 11y agoI used it very heavily and exclusively for about 3 months. I'm not writing it day to day now but it was like having super powers in comparison to writing JS or Coffee. I was using Visual Studio Community so I had all the benefits of intellisense (which is a big benefit), and I was able to manage a fairly complicated bespoke canvas thingo that suffered a few major refactorings - which I was able to perform with confidence due to the type checker. The massive list of bundled typings and 3rd party typings makes it much quicker to pick up a new API or remind yourself of one you haven't used for a while. I now write C# day to day and I find I don't spend the majority of my day alt-tabbing to and from documentation web pages as a result. So... any bad things to say? None at all off the top of my head. I'm a huge convert, and not because 'it's nice' or 'it's pretty' but because it's like wearing the Iron Man suit when it comes to programming. It's helped me be more productive on non-trivial projects.
- nkohari 11y agoI love TypeScript, and after spending a few years writing JavaScript and CoffeeScript, I've switched to using TypeScript whenever I possibly can. The only bad thing that I can say about it is that the management of type definition (.d.ts) files for external libraries can be a bit of a pain, even using tsd. That's less an indictment of the way TS works, and more of the tooling around it.
- jackweirdy 11y agoIt has a terrible type system
- agd 11y agoThe things missing for me are: 1. partial application (bind is typed as 'any') 2. sum type destructuring 3. issues with recursive type definitions But the Typescript team add new features very quickly so I wouldn't be surprised if these issues are solved in the future.
- Bahamut 11y agoThe type definitions for some libraries aren't super fleshed out, which prevents you from doing some of the optimal styles possible with those libraries. I ran into problems with both lodash and ramda with TypeScript so far. Other than those nuisances, I've grown to like using TypeScript a lot.
- Keats 11y agoThe type system is not that great and inference is quite limited. Definitions are not always existent or up to date and a single repo like definitelytyped is a terrible way to manage all the definitions. The above sounds negative but TS is still the best bet right now imo. Some people will prefer Elm or Purescript for better type systems but I like staying close to JS.
- d1plo1d 11y agoPersonally, I'm more excited about Flow because it introduces a modern type system into ES6/ESNext without me having to sacrifice Babel. With regards to types: TypeScript has only recently added support for any kind of Algebraic Data Types whereas Flow was built upon Unions and Intersections from day one. That to me speaks to their priorities.
- softawre 11y agoUnions were added in TS 1.4, over a year ago. https://blogs.msdn.microsoft.com/typescript/2015/01/16/announcing-typescript-1-4/ https://blogs.msdn.microsoft.com/typescript/2015/01/16/annou...
- WorldMaker 11y agoAlso, Intersections were added in TS 1.6, last year: https://blogs.msdn.microsoft.com/typescript/2015/09/16/announcing-typescript-1-6/ https://blogs.msdn.microsoft.com/typescript/2015/09/16/annou... They seem to be moving at a decent, agile pace to improving/expanding upon the algebraic sides of the type system.
- d1plo1d 11y agoYup, I was definitely wrong on that one. Sorry about that. Thank you for correcting me.
- WorldMaker 11y ago
- draw_down 11y agoLike other compile-to-JS languages such as coffeescript, I don't think it has enough to offer over plain JS to justify its existence. Coffeescript was great because it drove a bunch of language features into consideration for ES6, but actually writing in it seemed like more pain than it was worth. Consider being in the situation of being in charge of a large coffeescript codebase, today. No thank you.
- drumdance 11y agoFunny, I feel the exact opposite about CoffeeScript, but maybe I'm not using enough advanced features. In particular I like how readable and clean CoffeeScript is when you have a long series of callbacks.
- jkrems 11y agoTypeScript's type system is "occasionally typed". E.g. in trivial, C#/Java-style code it works well. And even there it falls back to `any` way too often (and it can become hard to find out way). Flow's type system is designed with modern, more functional style in mind and didn't fail me yet.
- spion 11y agoSuggestion that solves your problem: don't use TypeScript without "noImplicitAny"
- emodendroket 11y agoFor small projects with little client-side code it's more trouble than it's worth. But no, if you're doing serious JS development I think it's worth seriously considering.