May 25, 2020

ptemplates

Born to play

TypeScript 3.8 adds type-only imports and exports

TypeScript three.8, a new version of Microsoft’s typed superset of JavaScript, is now obtainable as...

TypeScript three.8, a new version of Microsoft’s typed superset of JavaScript, is now obtainable as a creation release. The latest TypeScript upgrade emphasizes kind-only imports and exports and ECMAScript specifications compliance.

The release provides a new syntax for kind-only imports and exports, with the intent of providing buyers much more great-grained management around import and elision. The import kind syntax only imports declarations to be employed for kind annotations and declarations and often gets entirely erased. The export kind syntax only presents an export to be employed for kind contexts and is erased from TypeScript output.

TypeScript has employed JavaScript’s import syntax to enable reference varieties. Whilst hassle-free, the capacity only worked because of the import elision element, which omits TypeScript kind imports when TypeScript outputs JavaScript documents. Even so, import elision has been both insufficient and problematic.

In conjunction with import kind, TypeScript three.8 also provides a compiler flag to management what occurs with imports that will not be employed at runtime: importsNotUsedAsValues.

With regards to the ECMAScript conventional for JavaScript, TypeScript three.8 provides help for ECMAScript private fields, which is element of a course fields declaration proposal for JavaScript. Public and private fields will be built-in into single, orthogonal entire, in accordance to this proposal.

Other advancements promised in TypeScript three.8 involve: