Microsoft announces TypeScript 3.0, which is now available for download through NuGet and NPM. If you are a developer and already using TypeScript to build your applications, check out what's new in this release of TypeScript version 3.0.
TypeScript is an open-source programming language, which extends JavaScript to bring static types to modern JavaScript. TypeScript language is designed, developed and maintained by Microsoft to provide developers the ability to develop JavaScript applications for both client-side and server-side (Node.js) execution.
TypeScript 3.0 focuses few new improvements that include project references, expansion of spread expressions with tuple types, generic rest parameters and corresponding inference of tuple types, the unknown
type, support for defaultProps
in JSX and more. For a complete list, check out 'What's new in TypeScript 3.0' section.
If you are using Visual Studio to build applications for TypeScript, either upgrade to Visual Studio 2015 Update 3 or Visual Studio 2017 15.2 or higher. The latest version of Visual Studio 2017 can be found here.
What's new in TypeScript 3.0?
TypeScript 3.0 introduces a new flexible and scalable way to structure your projects, support for operating on parameter lists, new types to enforce explicit checks, better JSX support, better error UX and most importantly some breaking changes. Here's the list of new changes in the latest version of TypeScript:
- Expansion of rest parameters with tuple types:
When a rest parameter has a tuple type, the tuple type is expanded into a sequence of discrete parameters.
- Expansion of spread expressions with tuple types:
When a function call includes a spread expression of a tuple type as the last argument, the spread expression corresponds to a sequence of discrete arguments of the tuple element types.
- Rest elements in tuple types:
The last element of a tuple type can be a rest element of the form ...X
, where X
is an array type. When no other elements are present, a rest element in a tuple is identical to itself.
- Optional elements in tuple types:
Tuple types now permit a ?
postfix on element types to indicate that the element is optional.
- Project references:
TypeScript 3.0 allows you to include references of other projects. It also allows you to reference a different tsconfig.json
file to make it easier to split your code into smaller projects.
- The new
unknown
type:
TypeScript 3.0 introduces a new type called unknown
, that allows you to describe the least-capable type in TypeScript.
- Support for
defaultProps
in JSX:
TypeScript now supports a new type alias in the JSX namespace called LibraryManagedAttributes
. It is a helper type that tells TypeScript what attributes a JSX tag accepts.
- Improved errors and UX:
TypeScript 3.0 gives a smarter, cleaner and more accurate error experience. In TypeScript 3.0, error messages can provide messages on other locations so that users can know the reason about cause-and-effect of an error.
- Other breaking changes:
- The deprecated internal method
LanguageService#getSourceFile
has been removed
- The deprecated function
TypeChecker#getSymbolDisplayBuilder
and associated interfaces have been removed.
- The deprecated functions
escapeIdentifier
and unescapeIdentifier
have been removed.
- The
TypeChecker#getSuggestionForNonexistentProperty
, TypeChecker#getSuggestionForNonexistentSymbol
and TypeChecker#getSuggestionForNonexistentModule
methods have been made internal and are no longer part of the public API.
How to download latest version of TypeScript 3.0?
If you are using NuGet Package Manager, you can download TypeScript 3.0 by entering the following command: Install-Package Microsoft.TypeScript.MSBuild -Version 3.0.0
. If you are using NPM, you can enter the following command: npm install -g typescript
to upgrade to the latest binaries. TypeScript supports a list of different editors. To use with Visual Studio, you need either Visual Studio 2015 Update 3 or Visual Studio 2017 15.2 or higher.
CodeProject