What’s New in TypeScript 4.7 Beta

TypeScript 4.7 Beta has just been released and is packed full of new features and changes. Today we’re going to talk about a few that I think stand out and give you the information you need to get your hands on this TypeScript beta.

ECMAScript module support in Node.js

ECMAScript is a JavaScript standard intended to ensure the interoperability of web pages on different web browsers. Node.js is built on top of a very different module called CommonJS, which made ECMAScript support a very difficult feature to implement. Experimental support for a few earlier builds was added in nightly builds to gather user feedback. Now, TypeScript 4.7 adds two modules to support this feature, node12 and nodenext.

        "module": "nodenext",

CommonJS interoperability

You can now import CommonJS modules as if they were ES modules with a default export. Node.js may also synthesize appointed exports from CommonJS mods in some circumstances.

// ./foo.cts
export function helper() 
    console.log("hello world!");

// ./bar.mts
import  helper  from "./foo.cjs";

// prints "hello world!"

Improved function inference in objects and methods

TypeScript 4.7 can now infer functions contained in objects and arrays with more granularity. This allows the types of these functions to flow consistently from left to right, just like ordinary arguments. You can see it in action below in this screenshot courtesy of Daniel Rosenwasser Senior Program Manager, TypeScript.


We’ve just scratched the surface of what’s been announced for TypeScript 4.7 Beta. There is a whole list of new features and changes with this beta which will soon become a release candidate. You can read all about them here. Leave us a comment below with what excites you the most!

To start using this version, you can use the following npm command.

npm install [email protected]

For those using Visual Studio Code, you can get editor support by following the instructions here.

Share this post:


Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top