官术网_书友最值得收藏!

Modules and imports

In vanilla JavaScript, you must have observed code blocks like this:

(function(){ 
var x = 20;
var y = x * 30;
})(); //IIFE
// x & y are both undefined here.

Modules are achieved in ES6/TS using the imports and exports syntax:

logic.ts
export function process(){
x = 20;
y = x * 30;
}

exec.ts
import { process } from './logic';
process();

These are the bare essentials that we would need to get started with TypeScript. We will look at more such concepts where needed.

With this we wrap up the key concepts needed to get started with TypeScript. Let us get started with Angular.

For more information on TypeScript, check out: https://www.TypeScriptlang.org/docs/tutorial.html. Also check out the TypeScript introduction video: https://channel9.msdn.com/posts/Anders-Hejlsberg-Introducing-TypeScript.

主站蜘蛛池模板: 定边县| 锦屏县| 新乡县| 青川县| 崇阳县| 铁力市| 榕江县| 金门县| 赤水市| 台湾省| 广州市| 越西县| 公主岭市| 张家界市| 酒泉市| 双辽市| 理塘县| 南开区| 太仓市| 孙吴县| 米易县| 五华县| 五华县| 宜城市| 太湖县| 巴林右旗| 惠水县| 惠东县| 颍上县| 大城县| 东兰县| 丹阳市| 华宁县| 宝应县| 沾益县| 全椒县| 江孜县| 新化县| 故城县| 汶川县| 二连浩特市|