TypeScript 3.8 adds type-only imports and exports
25 February 2020 | 0
The release adds a new syntax for type-only imports and exports, with the intent of giving users more fine-grained control over import and elision. The
import type syntax only imports declarations to be used for type annotations and declarations and always gets fully erased. The
export type syntax only provides an export to be used for type contexts and is erased from TypeScript output.
In conjunction with
import type, TypeScript 3.8 also adds a compiler flag to control what happens with imports that will not be used at runtime:
Other improvements promised in TypeScript 3.8 include:
- “Fast and loose” incremental type-checking, featuring a compiler option,
assumeChangesOnlyAffectDirectDependencies. This option can reduce build times in certain files, as TypeScript will recheck/rebuild only files that have changed as well as files that directly import them. It is recommended for large code bases where developers are willing to defer full project errors until a later time.
- Implementation of the export as * ns syntax, providing a single-entry point to expose all members of another module as a single member.
await, an upcoming ECMAScript feature to remove restrictions on using an
awaitexpression at the top of a file under specific conditions.
allowJsflag; type-checking of those files is supported via the
jsconfig.json lets users tell the compiler/language service which file watching strategies to use to keep track of files and directories.
- A refactoring to convert string concatenations.
- Stricter assignability checks to unions with index signatures, a breaking change.
- In another breaking change,
objectin JSDoc is no longer any under
You can install the general release of TypeScript 3.8 through NuGet or via NPM:
npm install typescript
IDG News Service