> This type can be used in classes and interfaces to represent some type that is a subtype of the containing type (rather than the containing type itself) Could that not be achieved by having covariant return types instead?
Sure, but that would require every subtype to override every method of the base type with a narrower return type, and do nothing except delegate to the base type in the body. It would be tedious boilerplate. Since the base type's implementation already returns `this`, it makes sense to be able to annotate the method as returning `this` and get the benefit automatically.
Announcing TypeScript 1.7
11–20 of 93 posts
Re: Announcing TypeScript 1.7
#12To me, this appears to be the way to go. Javascript + Typescript. Rather than deciding on weak (dynamic) typing vs strong typing, you pick both - incremental typing, as allowed by Typescript. Want to bang up a quick solution, as in MVP? Use bare-bones Javascript, it is all valid Typescript. So you get dynamic typing. And if you do not care about strong typing, you can just stop right there. But if you, some day, for…
Can TypeScript do runtime enforcement at the boundaries between typed and untyped code, though?
Re: Announcing TypeScript 1.7
#13Earlier quoted context omitted.
Can TypeScript do runtime enforcement at the boundaries between typed and untyped code, though?
This is a neat idea. Even with a significant perf hit, it could be used during development, testing, and debugging. You should propose this to the Typescript team! https://github.com/Microsoft/TypeScript/issues
Edit: It might have been this one: http://research.microsoft.com/apps/pubs/?id=224900
Re: Announcing TypeScript 1.7
#14Supporting async/await in ES5/ES3 is on the roadmap for TypeScript v2.0. https://github.com/Microsoft/TypeScript/wiki/roadmap
Re: Announcing TypeScript 1.7
#15To me, this appears to be the way to go. Javascript + Typescript. Rather than deciding on weak (dynamic) typing vs strong typing, you pick both - incremental typing, as allowed by Typescript. Want to bang up a quick solution, as in MVP? Use bare-bones Javascript, it is all valid Typescript. So you get dynamic typing. And if you do not care about strong typing, you can just stop right there. But if you, some day, for…
Can TypeScript do runtime enforcement at the boundaries between typed and untyped code, though?
Re: Announcing TypeScript 1.7
#16To me, this appears to be the way to go. Javascript + Typescript. Rather than deciding on weak (dynamic) typing vs strong typing, you pick both - incremental typing, as allowed by Typescript. Want to bang up a quick solution, as in MVP? Use bare-bones Javascript, it is all valid Typescript. So you get dynamic typing. And if you do not care about strong typing, you can just stop right there. But if you, some day, for…
Can TypeScript do runtime enforcement at the boundaries between typed and untyped code, though?
"Safe TypeScript: Safe and Efficient Gradual Typing for TypeScript"
http://research.microsoft.com/apps/video/default.aspx?id=226...
Re: Announcing TypeScript 1.7
#17Earlier quoted context omitted.
Can TypeScript do runtime enforcement at the boundaries between typed and untyped code, though?
Something like this? "Safe TypeScript: Safe and Efficient Gradual Typing for TypeScript" http://research.microsoft.com/apps/video/default.aspx?id=226...
Re: Announcing TypeScript 1.7
#18I missed it when I first read the blog post, so I figure it's worth emphasizing: the new async/await support is only available on JavaScript engines that already support "function*" generator functions: Node 4, Firefox, and Chrome, but not Safari or IE/Edge. Supporting async/await in ES5/ES3 is on the roadmap for TypeScript v2.0. https://github.com/Microsoft/TypeScript/wiki/roadmap
Re: Announcing TypeScript 1.7
#19To me, this appears to be the way to go. Javascript + Typescript. Rather than deciding on weak (dynamic) typing vs strong typing, you pick both - incremental typing, as allowed by Typescript. Want to bang up a quick solution, as in MVP? Use bare-bones Javascript, it is all valid Typescript. So you get dynamic typing. And if you do not care about strong typing, you can just stop right there. But if you, some day, for…
On top of that, tsc is possibly the fastest/easiest to use transpiler out there, which helps.
Re: Announcing TypeScript 1.7
#20To me, this appears to be the way to go. Javascript + Typescript. Rather than deciding on weak (dynamic) typing vs strong typing, you pick both - incremental typing, as allowed by Typescript. Want to bang up a quick solution, as in MVP? Use bare-bones Javascript, it is all valid Typescript. So you get dynamic typing. And if you do not care about strong typing, you can just stop right there. But if you, some day, for…
Actually, adding the bare minimum of type annotations (fields & function signatures) and type casts (e.g. casting whatever you get from querySelector into the concrete type of element) results in fewer key presses, because you can auto-complete everything and because you get additional machine-assistance like call tips and type checks.
So, you'll be actually faster if you add some types. Type inference does cover quite a lot. In practice, you'll need very few annotations and casts.
This Dart demo, for example, only needed a single type cast to be fully typed: