Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


 
 

Upcoming Features in TypeScript 1.5

Posted by Sandeep Chanda on Apr 7, 2015

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 "<the referenced file name>";

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

import { greet, …} from "<the referenced file name>";

Alternatively you can import all using the following syntax:

import * from "<the referenced file name>";

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.

TAGS:

JavaScript, modules, TypeScript


Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date