Dev News: Angular v16, plus Node.js and TypeScript Updates
“There are a lot of features/changes coming with this version. Much more than we have seen in any previous major release,” Mukherjee wrote. “Angular is seeing a kind of renaissance, and v16 is just the beginning.”
Among the changes he enumerates are:
- SSR with hydration, a long sought-after feature. “Without this, lot of developers who wanted to build an end-user-facing application where initial startup time and SEO is very important, withheld from using angular,” he noted.
- Required input for components. Angular developers have had to use hacks to enforce that inputs are getting passed to the component — unlike in React and other frontend frameworks. “Without this input being passed from the parent, [the] component may not work as intended,” he wrote. “This feature brings this much-requested feature in angular.”
- ngcc is out, completing the shift to ivy that started in v9. That should reduce Angular bundle side. Angular View Engine libraries can no longer be used after this, which he notes is a “hard break in compatibility.”
- Binding router information to component inputs, in which some router data will be available in the component directly as input. That means developers won’t have to use Activatedroute to get these specific values, which could remove a lot of boilerplate code from apps, he writes.
- takeUntilDestroyed and DestroyRef, which he said is another shift Angular is making toward “a more functional approach of writing code.”
- Signals, “are the new reactive primitive provided by Angular, which will help [the] framework track changes to its model,” he wrote. Some benefits this incurs include simplifying Angular by allowing the reactive primitive to replace rxjs in most cases and reducing app complexity; fine-grained reactivity; and fewer concepts to learn.
Node.js Offers Experimental Feature
Node.js introduced an experimental feature called the Permission Model, according to the feature contributor, software engineer Rafael Gonzaga.
“It allows developers to restrict access to specific resources during program execution, such as file system operations, child process spawning, and worker thread creation,” Gonzaga wrote. “The API exists behind a flag –experimental-permission, which when enabled will restrict access to all available permissions.”
Developers can use the feature to prevent apps from accessing or modifying sensitive data or running potentially harmful code.
Node v20.0.0 includes other changes as well, including custom ESM loader hooks running on a dedicated thread.
Using GitHub Actions Adds Security to NPM
Developers can now add a command flag that will publish details of a code’s origin by using GitHub Actions to build software packages for the npm registry, the Register reported Wednesday. That will enhance security, according to the article.
“GitHub Actions is a continuous integration and continuous delivery (CI/CD) platform, which provides a way to automate arcane command line input and software builds,” the Register wrote. “It’s often used by software developers to mechanize the build process for packages distributed through the company’s npm registry, which hosts more than two million of these modular libraries.”
Last week, npm made headlines after three attackers flooded the npm open source package repository for Node.js with bogus packets.
TypeScript 5.1 Beta Released
“That meant that even if you explicitly said ‘this function returns undefined,’ you were forced to have at least one return statement,” wrote TypeScript Program Manager Daniel Rosenwasser. “This could be a pain if some API expected a function returning undefined — you would need to have either at least one explicit return of undefined or a return statement and an explicit annotation.”
TypeScript 5.1 allows undefined-returning functions to have no return statement. Also, if a function has no return expression and is passed to something expecting a function that returns undefined, it will infer undefined for that function’s return type, the post explained.
To address another similar pain point, under TypeScript’s –noImplicitReturns option, functions returning only undefined now have a similar exception to void, in that not every single code path must end in an explicit return.
Other features in the beta release include:
- Unrelated Types for Getters and Setters
- Decoupled Type-Checking Between JSX Elements and JSX Tag Types
- Namespaced JSX Attributes
- typeRoots Are Consulted In Module Resolution
- Linked Cursors for JSX Tags
- Breaking Changes
Developers can access the beta through NuGet, or through npm with the following command:
npm install -D typescript@beta