News

TypeScript 2.0 Beta Supports Nullable Types

Besides support for nullable types, a beta of TypeScript 2.0 is now available that includes a smoother way of working with declaration files and makes module declarations more efficient.

A beta version of TypeScript 2.0 is now available from Microsoft, packed with a handful of features, including a smoother way of working with declaration files, support for nullable types, and simpler module declarations.

Declaration files are used to describe the shape of an external JavaScript library or host API, and a blog from Microsoft's Daniel Rosenwasser describes how the process of acquiring and declaring files is being simplified in version 2.0. Developers currently have to use package managers like tsd or Typings to use declaration files from the DefinitelyTyped declaration files repository (where library authors store .d.ts files).

"While very useful, these were extra tools to learn, and this added friction for new users," writes Rosenwasser, in a Github discussion posted here. "There were also some technical issues, such as lack of versioning and conflicting declarations, that existing tools couldn't manage." In beta 2.0, much of the process is being simplified so that developers just need to use the npm package manager to declare files.

In relation to file declaration, the TypeScript 2.0 beta has an easier way to declare modules. Modules can be declared without having to define their shapes until later. Wildcards can also be used in declarations for more efficient coding.

TypeScript 2.0 also includes two new types, null and undefined, which allows for nullable types. "They're not totally useful on their own, but you can use them in a union type to describe whether something could be null/undefined," writes Rosenwasser. It also adds a --strictNullChecks flag to check for the contents of a string.

Rosenwasser notes that handling of nullable types is a result of TypeScript 2.0's use of control flow analysis "to better understand what a type has to be at a given location," which has benefits in less debugging later on.

See Rosenwasser's blog here for some code samples, as well as links for getting the beta.

TypeScript is Microsoft's implementation of the JavaScript, a programming language for developing dynamic Web pages. TypeScript is considered a superset, adhering to JavaScript's language but allowing for extending of the JavaScript language. The latest version, 1.8, was released in February with JavaScript compilation improvements, expanded JSX support, and ChakraCore support.

About the Author

Michael Domingo is a long-time software publishing veteran, having started up and managed several developer publications for the Clipper compiler, Microsoft Access, and Visual Basic. He's also managed IT pubs for 1105 Media, including Microsoft Certified Professional Magazine and Virtualization Review before landing his current gig as Visual Studio Magazine Editor in Chief. Besides his publishing life, he's a professional photographer, whose work can be found by Googling domingophoto.

comments powered by Disqus

Featured

  • VS Code 1.123 Adds Agent Session Sync, 1M Context Windows

    Microsoft released Visual Studio Code 1.123 on June 3, adding agent-focused features, larger model context support, integrated browser updates and a new delay for some automatic extension updates.

  • Copilot Billing Shock Hits Developers

    Developer complaints about GitHub Copilot's new usage-based billing model have centered on unexpectedly rapid AI credit consumption, and neither GitHub nor Microsoft has responded directly to the backlash, though they have previously published guidance to lessen model usage costs.

  • Hands On with GitHub Copilot App Technical Preview: Turning a Blazor Issue into a PR

    GitHub's brand-new Copilot desktop app, in technical preview, handled a small Blazor issue from planning through pull request creation, but the hands-on test also showed why developers still need to verify agent work in the running app before merging.

  • At Build 2026, Microsoft Sets Up Windows as an OS for AI Agents

    Microsoft's Build 2026 Windows developer announcements point to a broader platform strategy for agentic AI, spanning terminal workflows, local models, app-building skills, Cloud PCs and operating system-level containment.

Subscribe on YouTube