Microsoft Announces TypeScript 3.0 (neowin.net)
Microsoft released version 3.0 of TypeScript, which Microsoft describes as an "extension" of JavaScript "that aims to bring static types to modern JavaScript." Quoting Microsoft's Developer Tools blog:
The TypeScript compiler reads in TypeScript code, which has things like type declarations and type annotations, and emits clean readable JavaScript with those constructs transformed and removed. That code runs in any ECMAScript runtime like your favorite browsers and Node.js. At its core, this experience means analyzing your code to catch things like bugs and typos before your users run into them; but it brings more than that. Thanks to all that information and analysis TypeScript can provide a better authoring experience, providing code completion and navigation features like Find all References, Go to Definition, and Rename in your favorite editor.
Neowin reports: With any major version release, it is not unexpected for breaking changes to be introduced and that's certainly the case for TypeScript 3.0. One obvious change is that with "unknown" becoming a new type, it is now a reserved type name and can no longer be used in type declarations. Otherwise, there's a range of API breaking changes due to a number of functions and internal methods being deprecated or being made internal.
On the plus side, TypeScript 3.0 reportedly has improved error messages, along with project references that let TypeScript projects have dependencies on other TypeScript projects.
Neowin reports: With any major version release, it is not unexpected for breaking changes to be introduced and that's certainly the case for TypeScript 3.0. One obvious change is that with "unknown" becoming a new type, it is now a reserved type name and can no longer be used in type declarations. Otherwise, there's a range of API breaking changes due to a number of functions and internal methods being deprecated or being made internal.
On the plus side, TypeScript 3.0 reportedly has improved error messages, along with project references that let TypeScript projects have dependencies on other TypeScript projects.
" emits clean readable JavaScript"
;)
Just my 2 cents
How else were we supposed to do things like hover states on navigation buttons?
CSS.
"You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
It does now, as do HTML input types and regular expression validators. That should cover most of the use cases of early JS, but not the current use of JS as a workaround for Windows, macOS, X11/Linux, iOS, and Android not being binary compatible.
I actually happen to like and appreciate Typescript. It was easy to learn-by-doing by going through the Angular [2-6] tutorials.
As a long-time Java programmer, I don't have to give up the type checking at the IDE level that really reduces the common coding mistakes you get with plain Javascript. You just get to tryable-then-working code faster. But you don't give up any of the flexibility that Javascript gives you. And the async/await functionality makes client-side programming just so much easier.
Does anyone else feel this way? Or is it just fashionable to hate it because Microsoft had something to do with it?
TypeScript compiles to JavaScript while at the same time you can mix it with pure JavaScript. This makes it easy to add TypeScript to an existing project. The fact TypeScript is based off of JS means it is easy for JS developers to learn it. Plus, you have something JS does not have: consistency. Want to use the class keyword in JS? You need to make sure all your supported browsers have implemented it and it'll work. In TypeScript you have several different compile targets depending on your lowest common denominator of JS version support you need.
TypeScript is a good solution to all the problems JS has, the most serious one I think being the lack of compile-type errors, pushing them to more difficult to find and fix runtime errors and logical errors.
TypeScript is more an annotation extension than anything else. It allows you to add the type of the parameters and method outputs as a development aid. This, coupled with a watcher process, checks your code as you type, and flags up when you pass an array to something that only uses strings, for example, or return a number instead of an object.
If something has already checked that the method only gets called with correct parameter types, you get to just write the code that does stuff instead of having to bloat the method with guard code.
Not having that extra code will give a (slight) speed increase as there's less to run.
"Wait. Something's happening. It's opening up! My God, it's full of apricots!"
I have a solid 18 yeats of experience with JavaScript. There is absolutely no point to TypeScript (or similar languages like CoffeeScript). They provide some cool syntax candy and "extend" the language in a sense, but in the end it just spits out pure JavaScript and adds a level of abstraction when it comes to debugging. If you're a good JS developer, you can write excellent, readable, well-organized, and maintainable code. And with ES6 you can write truly OO code with real classes and inheritance if that's your thing. Core JS is not perfect but is very powerful if you know how to use it. I've written entire single-page apps using core JS and jQuery, complete with controllers and data models. There is nothing that TypeScript really provides or improves upon other than a syntax closer to Java, which JavaScript is not! Oh and this nonsense about code completion and refactoring is just the icing on tbe cake. Most modern IDEs can already do this and have been doing it for years FFS. Gosh even Atom with pluggins can do that.