上QQ阅读APP看书,第一时间看更新
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.