Upcoming Features in TypeScript 1.5

Last week, Microsoft released an alpha version of its application-scale JavaScript in TypeScript 1.5. The language will now feature a plug-in for one of the most popular editors in Sublime Text. The 1.5 version will incorporate new concepts from ES6 and ES7 specifications in the form of Modules, which were introduced in ES6, and Decorators. TypeScript 1.5 syntax will allow you to define external modules and allow them to be imported with the ES6 style default import/export feature incorporated as well.

To define an export module you can use the export keyword before a function in your .ts file that is likely to be referenced.

export function greet(person) {              return "Hello" + person;}

For default import you can also use the default keyword:

export default function greet(person) {              return "Hello" + person;}

In your calling script, you can now reference the file containing the greet function and then import it.

import greet from "";

You can import multiple functions by wrapping them in curly braces.

import { greet, …} from "";

Alternatively you can import all using the following syntax:

import * from "";

TypeScript 1.5 will also support a new ES7 specification called Decorators. Decorators are a superset of metadata annotations. Decorators allow you to annotate and modify classes and properties at design time. The syntax is to precede the property or class you want to annotate. For example the following syntax shows how to create a ready only property:

class Person {  @readonly  name() { return '${this.first} ${this.last}' }}

In other examples of decorators, you can use the memorize to memoize an accessor.

To compile TypeScript in Node.js, you must create a git clone of the repository and then install the Jake tools and dependencies.

npm install -g jakenpm install
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Related Posts