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

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.

主站蜘蛛池模板: 大名县| 延长县| 尼木县| 闻喜县| 广西| 普兰店市| 永康市| 大同县| 双江| 湘潭市| 曲阳县| 泽州县| 荣成市| 五大连池市| 乌兰察布市| 海淀区| 泰和县| 青铜峡市| 鄂伦春自治旗| 双柏县| 大化| 马公市| 凉城县| 无棣县| 武汉市| 丹寨县| 吉木乃县| 阜宁县| 山东省| 灵山县| 东兰县| 金川县| 云龙县| 邹城市| 玉溪市| 遂昌县| 刚察县| 乌兰县| 阳曲县| 安西县| 桃园县|