4 ms·
Working on TypeScript 0.9: Generics, Overload on Constants and Performance
- camus 14y agomeh. While some constructs are great (class , modules , ...) some others dont make sense at all, unless you are using Visual Studio. Is typescript a javascript for Visual Studio or a language you can really use without MS tools ? Also the fact that you cant compile to 1 file automatically all your scripts and you need either AMD or Common JS defeats the purpose of having modules for client side scripting.
- vladev 14y agoIntelliJ already provides decent support for it, including auto-completion. I assume with the new pull-based type checker similar things can be done for vim, emacs, etc.
- lucian1900 14y agoIt's possible to instruct tsc to compile into called-closure style modules, then concatenate them if you really want that.
- seandhi 14y agoThat is exactly what we are doing with an in-house TypeScript framework that we have written. The compiler checks the dependencies recursively and then concatenates them in a single file. It is careful not to duplicate dependencies, too.
- bokchoi 14y agoThe overload on constants pattern matching is an interesting feature.
- spo81rty 14y agoLooks like some great improvements. In some ways having to declare the generics may slow down coding but will improve quality greatly.
- domlebo70 14y agoHow are they planning on structuring the collections methods? Is map going to be on Arrays, and Maps and Lists etc? Or will they utilize some sort of typeclass approach and have them as modular as possible?
- asolove 14y agoThey aren't planning to add collection methods, just to provide a means for existing methods like Array#map and Array#filter to be typed. Right now there is no way to write a type signature that says, given an array of numbers and a function from numbers to strings, Array#map returns an array of strings. This allows that.
- SideburnsOfDoom 14y agoI like strongly typed languages and generics, but I see generics as adding a complexity to a type system in order to get around the limitations of the type system. Javascript, on the other hand, is duck-typed. Everything is the equivalent of generic already. Adding generics to the Javascript wrapper feels awkward and overcomplex and somehow suggests that a point has been missed. Perhaps you feel differently?
- AndrewDucker 14y agoHow do you guarantee that what is added to a list (for instance) is a Dog, and not a Cat? If you want strongly typed language support (and I do), then generics make it vastly easier to write maintainable code. A generic doesn't mean "anything goes" - it means "You will definitely get the thing that you specified".
- SideburnsOfDoom 14y agoIn Javascript or any other duck-typed language, you don't have that guarantee. You don't actually care that it's a Dog BTW, just that it has a method called Bark(), if that's what you call on it. You make sure that your code only puts dog-like objects into the list, either by writing tests or by reading the code and praying. But the system of putting objects into lists is really, really simple. I see the benefit of strong typing and I use it all the time. Generics are an epicycle that IMHO sits poorly with JavaScript.
- AndrewDucker 14y agoExactly. This is _not_ Javascript. It's Typescript, which compiles into Javascript, but adds in guarantees that, for instance, what I'm getting _is_ a dog.
- SideburnsOfDoom 14y agoTypescript is not JavaScript, but all JavaScript is TypeScript, including JavaScript that works as discussed above. It's just a bit funny that in Typescript are both a language that benefits from having generics and a language that doesn't need them.