TypeScript 3.6 Generators Get Stricter |
Written by Kay Ewbank |
Friday, 30 August 2019 |
TypeScript has been updated with stricter generators, improvements to the UX around Promises, and an improved TypeScript playground. TypeScript is a superset of JavaScript that adds optional static types which can be checked by the TypeScript compiler to catch common errors in your programs. Tools like the TypeScript compiler and Babel are then used to transform TypeScript to standards-compliant ECMAScript code that will work on any browser or runtime. TypeScript includes editor support for Visual Studio 2015 and 2017, Sublime Text 3 and Visual Studio Code. The first change to the new version is the introduction of stricter checking for iterators and generator functions. Until now, if you used a generator there was no way to differentiate whether a value was yielded or returned from a generator. Changes have been made in the Interator and IteratorResult type declarations to include new type parameters, and to a new type that TypeScript uses to represent generators called the Promise handling has also been improved, so that if they are mishandled in your code, for example by forgetting to include an await to make sure the Promise has been fulfilled before passing it to another function, you'll now get a clearer error message explaining this. Array spreads are another area to be improved. Until now, TypeScript has used a simplified emit by default for constructs like The TypeScript playground is another area to be improved with new options including:
The options also persist when sharing links to playground samples.The developers say that they'll be refreshing the playground samples in the near future, adding JSX support, and polishing automatic type acquisition, meaning that you’ll be able to see the same experience on the playground as you’d get in your personal editor. More InformationRelated ArticlesTypeScript 3.5 Adds Smart Select TypeScript 3.2 Gets Stricter Checking TypeScript 3.1 Adds Mappable Tuples TypeScript 3.0 Adds Project References TypeScript Adds Unused Span Reporting TypeScript Adds Conditional Types TypeScript 2.7 Improves Type Inference TypeScript 2.5 Adds Optional Catch Binding TypeScript 2.4 Adds Dynamic Import Expressions TypeScript 2.2 Adds More Code Actions
To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
Comments
or email your comment to: comments@i-programmer.info |
Last Updated ( Saturday, 31 August 2019 ) |