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

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.

主站蜘蛛池模板: 基隆市| 祁东县| 阿克苏市| 万州区| 庆安县| 高密市| 鹤壁市| 浦江县| 丹凤县| 沧源| 耒阳市| 仙居县| 镇雄县| 明光市| 丰都县| 扎赉特旗| 宁陵县| 礼泉县| 彰武县| 贡嘎县| 铁岭县| 富阳市| 开封市| 河北区| 博罗县| 新源县| 大同市| 延长县| 桂阳县| 隆尧县| 文成县| 德安县| 桂阳县| 石门县| 嫩江县| 浮梁县| 高唐县| 金乡县| 舞阳县| 高尔夫| 邹平县|