TypeScript 3.8 beta adds support for ECMAScript private fields

Share
  • January 13, 2020

TypeScript, the superset of JavaScript, offers minimal configuration management and IDE support, while still providing the benefit of JavaScript libraries. It adds optional static type-checking and type syntax and works with all browsers and operating systems.

Released on January 10, 2020, TypeScript 3.8 Beta includes features that users can expect to find in the final version. Give the beta a try and familiarize yourself with what is coming in the final release.

This version includes the support and collaborative efforts of the Bloomberg engineering team.

SEE ALSO: How can you make a JavaScript website successful in Google?

v3.8 beta features

Daniel Rosenwasser, TypeScript program manager, dives deep into the new features in the Microsoft announcement post.

Take a look at the recent arrival. Some of the highlights of v3.8 beta include:

Private fields

Thanks to contributions from Bloomberg, support for ECMAScript’s private fields arrives. It is currently in the third stage of development, which indicates that further refinement and feedback are needed before it is included in the formal ECMAScript standard.

Rosenwasser notes that with the introduction of private fields comes a few new rules.

  • Private fields start with a # character. Sometimes we call these private names.
  • Every private field name is uniquely scoped to its containing class.
  • TypeScript accessibility modifiers like public or private can’t be used on private fields.
  • Private fields can’t be accessed or even detected outside of the containing class – even by JS users! Sometimes we call this hard privacy.

View more information about public and private class fields in the proposal.

     

    International JavaScript Conference
    Manfred Steyer

    The Future of Angular and your Architectures with Ivy

    by Manfred Steyer (SOFTWAREarchitekt.at)

    Andrey Goncharov

    React: Lifting state up is killing your app

    by Andrey Goncharov (Hazelcast)

     

    Syntax for importing/exporting type-only

    One of TypeScript’s features is that it reuses JavaScript’s import syntax using the import elision feature. However, despite its benefits and ease of use, it could cause problems when importing a value or type, leaving it ambiguous after being exported. Import elision also caused other troublesome issues such as removing import statements that only contained imports used as types.

    Now, TypeScript 3.8 beta adds a new syntax for type-only importing and exporting that will fix the aforementioned issues.

import type { SomeThing } from "./some-module.js";

export type { SomeThing };

View the original pull request on GitHub.

Miscellaneous updates

Other features and changes arriving with 3.8 beta:

  • New ECMAScript 2020 syntax: Improved syntax added to JavaScript and TypeScript 3.8: export * as utilities from “./utilities.js”;
  • Top-level await: This adds an upcoming ECMAScript feature. View the top-level ‘await’ proposal (currently in stage 3).
  • Supports  es2020 as option for module and target
  • New compiler option: assumeChangesOnlyAffectDirectDependencies
  • Breaking change: object in JSDoc is No Longer any Under noImplicitAny
  • Stricter type-checker: The type-checker now only exempts properties from excess properties checks if the property involved could potentially satisfy an index signature.

SEE ALSO: The State of JavaScript 2019: Developers love React and TypeScript

Updating TypeScript


Update and test out the newest features by downloading it via NuGet. Or, update through npm with the npm install typescript@beta  command.

As this version graduates from beta to its final release, the development team will continue fixing bugs and polishing it up for its debut. Beta testers can helpful feedback for the development team about potential bugs, errors, or issues to ensure a smooth release.

Refer to the 3.8 iteration plan for upcoming dates, notes, and current work items.

The final release of TypeScript 3.8 is planned to arrive on February 18, 2020. 

The post TypeScript 3.8 beta adds support for ECMAScript private fields appeared first on JAXenter.

Source : JAXenter