
TypeScript 2.1 RC: Better Inference, Async Functions, and More - DanRosenwasser
https://blogs.msdn.microsoft.com/typescript/2016/11/08/typescript-2-1-rc-better-inference-async-functions-and-more
======
WorldMaker
This is a great release. I know a lot of people have been waiting for
async/await downlevel support (transpiling async/await to ES3/ES5 for use in
contemporary and older browsers), including some of my own projects.

Better type inferencing of course makes writing code better for everyone.

Also, somewhat buried in this announcement is showing off support for more
modular lib.d.ts support, which is also something that has been patiently
needed. (Up to now the basic types and expectations of the target ES version
you were transpiling to were in big monolithic definition files making it
harder to "pick and choose" as needed for your project: the most common case
being one shown here that most browsers support native promises from ES2015
and/or are easily polyfilled, but you still want to mostly stick everything
else to ES5 output code for the time being.)

~~~
WayneBro
I was just trying to get a async/await working in react-native and I kept
running up against various errors. Maybe I should wait until Typescript 2.1 is
released and just use that.

~~~
DanRosenwasser
Hey, I'm the PM on the TypeScript team and I'm curious to hear about the
issues you ran into. async/await already works in TS 2.0 when targeting ES6,
so you should have had a good experience in that respect. Feel free to DM me
on Twitter at @drosenwasser.

~~~
WayneBro
Oh I was actually using the default react-native config which I assume is ES6.
So, I was just saying that I was considering switching to TypeScript instead.

It surprised me that async didn't seem to work by default in react-native
because their documentation stated support for it very plainly. Maybe it's
because I was on Windows or because I am using Node v4.

Thanks for the offer but I will probably continue to slog through this on my
own. I'm really just getting started with React even though I've been reading
about it forever. I don't know TypeScript very well either but maybe I will
start learning!

------
ciconia
I'm definitely behind the times with regard to what's happening in the
Javascript world, but for me Typescript was nothing short of a revelation! It
makes it just so much more easy and pleasant to code anything with any
reasonable amount of complexity.

Sincerely, Microsoft, bravo!

------
grayrest
Does the new inference allow incremental construction of objects?

    
    
        interface Color {
            isRed: boolean,
            name: string
        }
    
        function example(): Color {
            let x = {};
            x.isRed = false;
            x.name = "Cerulean";
            return x;
        }
    

Obviously you'd just build the object at once for something this simple, but
for larger/more complex objects it becomes trickier.

