Code can be found here.
ECMAScript 5 (ES5) is the Javascript version ECMAScript 2015 (ES6) released in 2015 (big game changer for javascript language features) ECMAScript 2016/2017 (Nothing new really)
Polyfills are used for features that are not yet supported by all browsers
Can Not Use tells you what javascript versions and things cant be used on some browsers
Compilers go from High Level to Machine
Transpilers go from Typescript to ES2015 ( Syntactical and structural )
Visual Studio Code - build task (lightweight)
Angular CLI is using Webpack!
tslint helps you write clean code
Lot of similarities of C# and Typescript
class SomeClass extends MyBase{
private _somevar: string = "Yeah";
public message: string;
constructor(){
super();
}
get someProp() : string{
return this._somevar;
}
set someProp(value: string) : string{
this._somevar = value;
}
someMethod(): number{
return 42;
}
}
Visibility modifiers and types are present on Typescript not, ES2015
(function(){
var item = "A";
})();
item
is local to the function, removes the issue of global namespacing problems
tslint.json is a configurable file that modifies tslint
codelyzer brings in angular specific syntax analyzing
Visiblity modifier = Public/private is typescript
Backticks are used as quotes now.
const result = `Hello ${this.name}, are you ${5 + threshold} years old?`;
let and const are block scoped.
someMethod(){
this.startEngine().then((result) => { ... },
(error) => { ... });
}
Arrow functions means, this means this.
const promise = new Promise<string>((resolve, reject) => {
doSomething(){
resolve("Cool stuff");
}
return promise;
});
To consume the promise: sc.startEngine2().then( result => console.log(result), error => console.error(error) );
Better method, cleaner: try{ const asyncResult = await sc.startEngine(); } catch (error){ console.error(error); }
.then, .catch, .finally can be used.
public name: string = 'Barney';
private f: number = 42;
getUntypedObject() : any {
return { answer:42, fav: "coolio" };
}
noImplicitAny = true, true doesn't allow any to be used
export interface blah{ }
@Component({
....
})
export class CustomerListComponent{}
Allows you to specify metadata
Put await in front of call to something that returns a promise Put async in front of function, method, or property declaration
Copyright © 2017 | Glenn Dayton