Modal Title
Frontend Development / Rust / Typescript

TypeScript 5.0: New Decorators Standard, Smaller npm

In developer news this week, TypeScript 5.0 incorporates decorators, while React gets a document page overhaul and Rust has a minor update.
Mar 24th, 2023 11:25am by
Featued image for: TypeScript 5.0: New Decorators Standard, Smaller npm

TypeScript 5.0 shipped this week, with support for the new decorators standard and a smaller npm footprint than TypeScript 4.9.

Microsoft’s Daniel Rosenwasser, programmer manager for TypeScript, explained the changes in a blog post, promising that 5.0 “is not a disruptive release, and everything you know is still applicable.” TypeScript 5.0 includes correctness changes and some deprecations for infrequently-used options, he added.

“This release brings many new features, while aiming to make TypeScript smaller, simpler, and faster,” Rosenwasser said. “We’ve implemented the new decorators standard, added functionality to better support ESM projects in Node and bundlers, provided new ways for library authors to control generic inference, expanded our JSDoc functionality, simplified configuration, and made many other improvements.”

Decorators are used in Python, Java and C# and are a stage 3 proposal for JavaScript. Currently, they can be used in JavaScript via Babel and the TypeScript compiler, according to senior software developer Lawrence Eagles. Most browsers do note support decorators presently.

“Decorators, in a nutshell, involve wrapping a piece of code such as a function or a class with another — a decorator function. The aim is to extend the functionality of the wrapped code without modifying it,” wrote Eagles. “Decorators are very powerful and they have a wide range of applications.”

Among the use cases are turning the class method into REST, logging useful information and enabling code reuse, he added.

The new release also offers a smaller typical npm package size, at 37.4 MB compared to 63.8 MB for Typescript 4.9, according to Rosenwasser’s write-up.

TypeScript builds on JavaScript by adding syntax for types that can be used for type-checking, Rosenwasser said. To get started using TypeScript 5.0, you can get it through NuGet, or use npm with the following command:

React.dev Launches New React Home

In other news from the week, React.dev is nearing its 10th birthday. To celebrate, it has launched a new home for the popular library and related documentation. The site teaches modern React with function components and hooks, and features more than 500 new interactive examples and sandboxes.

The previous documentations site is archived at legacy.reactjs.org. The original domain — reactjs.org — will redirect to the new site.

The updated docs teach React with Hooks from the beginning and are divided in two main sections, according to a blog post by developers Dan Abramov and Rachel Nabors:

  • Learn React, a self-paced course that teaches React from scratch and incorporates a “show solution” button for those who get stuck.
  • API Reference, which provides the details and usage examples for every React API. Every API page includes information about reference and usage, with usage showing why and how a developer would use an API in practice.

The new site offers a quick start page for those wanting to learn React, along with an interactive Tic-Tac-Toe tutorial that teaches developers to build a version of the game. It also includes an update to Thinking in React, which Abramov and Nabors said is “the tutorial that made React “click” for many of us.

React remains one of the most popular and widely used JavaScript libraries, according to the 2022 State of JavaScript survey.

Rust Update to 1.68.1

Finally, Rust published a new point release, Rust 1.68.1, on Thursday. Point releases are minor, typically fixing bugs or performing code cleanup. In this case, Rust 1.68.1 contains a change to how Rust’s CI builds the Windows MSVC compiler, no longer enabling LTO for the Rust code.

“This led to a miscompilation that the Rust team is debugging, but in the meantime, we’re reverting the change to enable LTO,” the Rust team stated in a blog post. “This is currently believed to have no effect on the wider usage of ThinLTO. The Rust compiler used an unstable flag as part of the build process to enable ThinLTO despite compiling to a dylib.”

Other regressions fixed in the release:
Fix building the compiler with –enable-local-rust;
Treat $prefix-clang as clang in linker detection code; and
Fix a panic in the compiler.

Group Created with Sketch.
THE NEW STACK UPDATE A newsletter digest of the week’s most important stories & analyses.