NewsCrawler.org

TypeScript 7.1 release candidate adds import attributes and source phase imports

TypeScript 7.1 release candidate adds import attributes and source phase imports
Performance of TypeScript 7.1 RC, as described by table below
Image: Reddit

The TypeScript team announced the release candidate of TypeScript 7.1, which can be installed with npm install -D typescript@rc. Since the beta, the release candidate brings faster speed and lower memory use, API improvements, stronger defaults for content mapper packages, a new --disableDynamicImportExtensionRewriting option, and an experimental WebAssembly[1] package that helps TypeScript 7.1 run in browsers and WASI[2] runtimes.

TypeScript 7.1 adds support for import attributes[3] in ambient module declarations[4]. For example, declare module "*" with { type: "css" } gives CSS imports the type CSSStyleSheet, and importing a file without the required attribute produces an error. These declarations are not checked against files on disk, and they are not part of TypeScript's built-in libraries, so libraries should not include them in their published packages. Previously, wildcard patterns such as *.css ignored import attributes entirely.

The release also covers source phase imports, a proposed ECMAScript feature that uses the import source keyword. Such an import returns a module object after it is parsed but before its imports are loaded; for WebAssembly, this object is a WebAssembly.Module that can be passed to WebAssembly.instantiate. Source imports keep their identity, so they can be used in Maps and Sets and compared reliably. For JavaScript files, source imports can do little yet, since many environments and tools do not support them.

Repository TypeScript github.com

TypeScript is a superset of JavaScript that adds static types and compiles to plain JavaScript output.

Stars: 110,000Forks: 14,000License: Apache-2.0Updated:

Read the original devblogs.microsoft.comDiscussion

Sources

Published: First seen: Читать по-русски

Open as a page