top | item 10990765

Announcing TypeScript 1.8 Beta

256 points| DanRosenwasser | 10 years ago |blogs.msdn.com | reply

82 comments

order
[+] bunkerbewohner|10 years ago|reply
This is brilliant! The first three features, i.e. --allowJs, --reactNamespace, and stateless functional componentshave been precisely the things that I have been missing recently.

This makes integrating 3rd party JS libs much easier and I can streamline my components a little since I'm almost exclusively using stateless components anyway.

That already made me quite happy. But as I'm reading on I almost can't believe all the other great additions, such as module augmentations, string literal types, AMD module concatenation, let/const in loops. It's like they've been reading my mind. These were all things on my wishlist. Great work!

[+] rekoros|10 years ago|reply
TypeScript is amazing. We decided on TS to build https://sameroom.io and never looked back!
[+] meowface|10 years ago|reply
Cool application. It's something I've wanted for a while, and I'd probably use it. But linking it here apropos of almost nothing seems a little like shilling.
[+] jonesb6|10 years ago|reply
My dream is to have enough free time to rewrite a large open source project from es5/6 to typescript. One day..

Edit: I meant refactoring as a way to improve the project, learn typescript, and learn the project itself inside and out.

[+] nothrabannosir|10 years ago|reply
I don't know if you're setting me up for a joke here, but you're putting the ball an inch away from an open goal:

Javascript is Typescript. Typescript ⊇ Javascript.

Especially if you already use Babel (or any other JS preprocessor, like uglify or concat) and have a build pipeline ready, you can start using Typescript today.

Don't miss out!

PS: It will throw a lot of errors on a conventional codebase, but compile despite them. That's the point; install the compiler today, slowly start fixing the errors as you go. It's all about gradual improvement and optional typing.

[+] girvo|10 years ago|reply
I had the same dream... so I started using Flow[0]! Put all of my codebase in /* @flow weak */ to start, then slowly tightened it up with more type hints, declarations, etc.

[0] http://flowtype.org/

[+] igl|10 years ago|reply
I recently learned that the TS type-checker is unsound on purpose and i am a bit disappointed.

http://tryflow.org/#2944d91c10fc5d76faeebbb20cac466a Try this snippet in TS.

[+] altano|10 years ago|reply
Regarding the unsoundness-by-default, I wish "--no-implicit-any" was the default but it's really no big thing to just add this flag to any project.
[+] altano|10 years ago|reply
Why is this line an error?:

> var cats : Cat[] = [ new Cat() ]

[+] breck|10 years ago|reply
"For example, for a quick ES6 to ES5 downlevel conversion using the TypeScript compiler, you just need the following command: > tsc --allowJs --outDir out target_file.js"

Is the intent here to allow tsc to be used as a replacement for babel?

[+] scott_o|10 years ago|reply
I don't think so. Last time I checked they don't do any polyfills, instead relying on commonJS for that.
[+] nikolay|10 years ago|reply
I am really puzzling what is Microsoft trying to accomplish here? Eventually a C# that compiles to JavaScript? TypeScript is a great language, and surprisingly (or not) it's more successful than Dart. Now, of course, I want TypeScript to compile to CLR as well. :)
[+] Analemma_|10 years ago|reply
I think people read into TypeScript too much. It's just a "right-now minimal-hassle" way to make front-end dev's lives easier, nothing more.

Maybe Microsoft disagrees, but I see TypeScript as something intended to make itself obsolete: eventually, when all browsers are running ES9 (or whichever version we decid has fixed "all" of JavaScript's problems) or WebAssembly (and we're all writing front-end code in C#/C++/Ruby/whatever), then TypeScript will just fade away, by design. For now, it's kinda like JQuery in motivation if not literally architecture: it shields you from browser inconsistencies (in this case, where you don't know what ES version the target is running) and helps you avoid JavaScript's headaches. Just as JQuery became less necessary as time went on-- not because it got worse but because browsers got better-- so too will TypeScript.

[+] altano|10 years ago|reply
> Eventually a C# that compiles to JavaScript?

That actually existed internally at MS, along with many other projects to improve developing large JS codebases, most of which have fallen by the wayside. There was even a Flow-like compiler that worked with type annotations in comments. TypeScript has won out, although there is a LOT of code written in these other projects.

[+] itslennysfault|10 years ago|reply
TypeScript is a proper superset of JavaScript so it's an easy choice over dart IMO (even google's angular2 team chose it).
[+] pippy|10 years ago|reply
I love TypeScript - it's my favorite precompiled language and I use it for a few personal projects of mine. But I can't help but feel it's an evolutionary dead end. asm.js / web assembly is what you want transcompiled languages to target
[+] moonchrome|10 years ago|reply
Asmjs/webasm are orhogonal to TS - they even have to manually manage memory
[+] peteretep|10 years ago|reply
I don't really understand your comment. What about Typescript precludes it from targetting web assembly or asm.js in the future?
[+] ybx|10 years ago|reply
Someone in Mozilla came up with a language called LLJS, that took full advantage of and compiled down to asm.js.

It looked like it had some promise, since it wasn't nearly as heavy as emscripten, but I don't think much has happened with it since it was created.

[+] _pmf_|10 years ago|reply
It would be refreshing if the ES evolution would take some hints from TypeScript instead of satisfying the perceived need for syntactic sugar and cutesey poor man's FP.
[+] VeilEm|10 years ago|reply
> While React has paved the way, JSX syntax is not only tied to React.

Does TypeScript manage the lifecycles of elements you create through their version of JSX? React creates an in memory version of the DOM and reconciles changes to the DOM against this. Is TypeScript doing this too or is this simply template syntax inside JavaScript? What React does is not simply template syntax. HTML and JSX are totally different things! JSX renders to HTML eventually, but there's way more going on.

[+] saidajigumi|10 years ago|reply
According to https://github.com/Microsoft/TypeScript/wiki/JSX, there are two JSX processing options. The first is a JSX passthru ("preserve" mode) and the second ("react" mode) will generate React.createElement, etc. See that page for the technical details.

As such, preserve mode is intended for use with other backends, e.g. those listed under Transpilers at https://facebook.github.io/jsx/. Whichever non-React backend you choose therefore defines the JSX runtime handling rather than having that baked into TypeScript.

[+] Guillaume86|10 years ago|reply
You're mixing up React and JSX. Typescript do not replace React, it just allows JSX syntax and transforms it to javascript for you if you want.
[+] crudbug|10 years ago|reply
When can we see CoreCLR backend for TypeScript ?
[+] chinhodado|10 years ago|reply
What do you mean by that?
[+] scotty79|10 years ago|reply
Still no love for typing of `this` or `call()` and such
[+] Ycros|10 years ago|reply
Can you elaborate on what you mean by that? 1.7 added 'this' typing improvements, and it looks like 1.8 is adding 'this'-based type guards.
[+] z3t4|10 years ago|reply
I think type-script is great. But what's true for every bug that ever existed!? It passed the type checker!
[+] slantview|10 years ago|reply
[+] jbrantly|10 years ago|reply
I don't think this applies. I don't believe anybody else was doing what TypeScript does when it was released, that is JavaScript + Type Safety. Even today the only other real contender is Flow.