Some typescript key takeaways



1. A module can only have a single default export. Yes only one. Please don't try to use multiple. There is no workaround.

2. You can export a class / interface like this :-

export = ZipCodeValidator;

3. And import it using 

import zip = require("./ZiCodeValidator");

4. Optional loading

Yes, you can define optional loading but Typescripts does this for you automatically. In nodejs, require.js or system.js, you might have to do it manually.

5. Working with other javascript libraries

This gotta sounds catchy...

6. Generator functions

You can have multiple yield statement like so.

function* generateIt()
{
   yield 1;

  yield 2;

  yield 3;

}

var myvar = generateIt()

To pass a value to your generator function.

let myfunc  = generateIt();
myfunc.next().value;   // return 1










Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm