TypeScript 4.5 Beta Released
TypeScript, the corporate savior has received a new release, 4.5 beta. In it, we have a couple of interesting novelties, such as (this is a non-exhaustive list):
- ECMAScript Module Support in Node.js
- Template String Types as Discriminants
- --module es2022
- Tail-Recursion Elimination on Conditional Types
- Private Field Presence Checks
- Faster Load Time with realPathSync.native
- Snippet Completions for JSX Attributes
- Better Editor Support for Unresolved Types
EcmaScript Module Support
ES Modules are by no means anything new. For the past few years, a lot of work had been done to better support them in Node, as historically, the basis for everything were CommonJS modules, which was the default option. There are pretty notable differences:
- Top level await;
- import/export statements;
- and more;
The TypeScript compiler now enables two new extension names - .mts, and .cts. Upon compiling, .mts files will be compiled to the newer ES Modules and .cjs to the older CommonJS modules. There is also new support for the exports field in package.json, and there is a compatibility import statement that allows for easy interop with the older modules. For details, see Microsoft’s blog post.
The Awaited Type
The new Awaited type aims to help developers with typing the results of await/async operations, AND the results of the .then() method on Promises. For details, read this thread on GitHub.
Faster Load Time with realPathSync.native
TypeScript has embraced a native implementation for Node’s realPathSync - a function used to compute a “canonical pathname” of a file. Previously used only on Linux, the native implementation is now used on Windows, and macOS as well. Certain projects can benefit from a “5-13%” improvement in the project’s load time.
There are some breaking changes, however, which you should definitely examine in detail: lib.d.ts changes, “inference changes from Awaited”, and compilerOptions changes. See the details here.
Ethereum: the platform of choice for Web 3.0 developers
Cryptocurrencies are still a controversial topic. For some, they are a scam, merely enabling money laundering. For others, they are a financial revolution unlike any that we've seen before. Regardless of your stance on the topic, there is a new branch of the internet developing. It’s the decentralized Internet, or “Web 3.0”. It so happens, that 60 to 70 percent of the whole industry currently runs on top of Ethereum’s blockchain.
This reliance on Ethereum creates several problems. First, the network’s capacity is “severely limited.” It is currently only at 15 transactions per second, which is an enormous problem, as this makes transaction fees sky-high. The newer solutions, built on top of Ethereum’s blockchain, run on additional layers on top of it, which increase the possible transaction rate significantly.
It is not a solution to the problem, however, and merely a workaround. Another problem is that the blockchain is behind on modernization. The switch from the current “proof of work” algorithm to the new “proof of stake” one is overdue, for example. Another change is the database sharding, or in other words, splitting it into multiple separate (but linked) instances.
This creates space for other blockchains to shine - including Avalanche, Solana, and Cardano. While they are not as popular, they solved the scaling issue but not the availability problem, however, as recently Solana went out for 17 hours.
There are exciting times ahead for all Web3 developers, as the decentralized web will enjoy more and more popularity with some browsers, such as Brave, aiming to simplify the experience of using the next iteration of the web.
China releases its first set of guidelines on AI ethics
China released a set of guidelines on AI ethics, (draft here, in Mandarin) “emphasizing user rights and data control.” The overarching goal is to become the global AI leader by 2030. The set of guidelines was called “the most comprehensive effort by any country.”
Rebecca Arcesati from the Mercator Institute for China Studies commented on the set of released guidelines:
China is ultimately opting for a heavy-handed model, where the state is thinking very seriously about the long-term social transformations that AI will bring, from social alienation to existential risks, and trying to actively manage and guide those transformations
Furthermore, the move can be seen as another one of the moves aiming to bring the Big Tech under control. Over the past few months, the Chinese government looked to punish all platforms that do not respect user privacy, data guidelines, or those adopting addictive practices. The biggest players were not spared from the purge - the list of companies includes Tencent, Alibaba, and ByteDance. The new set of rules regarding AI are a very serious deal - there are whole businesses built on the grounds of AI and what AI enables, such as content recommendations or indexing data.
AI Writing Your Tests
An absolutely crucial part of the software development process is writing tests for quality assurance. It is a process that is unfortunately often overlooked, as it is seen as too time-consuming. The authors of Ponicode surely know this, which is perhaps why they created their product.