SJavaScript:
"The Good Parts"
Douglas Crockford
ecmascript
Anders Hejlsberg
I invented
Turbo Pascal,
Delphi and C#
function sum(s) {
return s + s;
}
function square(x) {
return x * x;
}
JavaScript
function sum(s: string) : string {
return s + s;
}
function square(x: number) : number {
return x * x;
}
TypeScript
interface Post {
text: string;
title?: string;
author: string;
type: 'post' | 'comment';
}
@Component({
selector: 'post',
template: '<div>My post</div>'
})
class PostComponent {
...
}
let myPost: Post = { }
// Type '{}' is not assignable to type 'Post': Property 'text' is missing
declare module Backbone {
export class Model {
constructor (attr? , opts? );
get(name: string): any;
set(name: string, val: any): void;
set(obj: any): void;
save(attr? , opts? ): void;
destroy(): void;
bind(ev: string, f: Function, ctx?: any): void;
toJSON(): any;
}
export class Collection<T> {
...
}
}
npm install @types/backbone --save-dev
// package.json
"dependencies": {
"backbone": "^1.3.33"
},
"devDependencies": {
"@types/backbone": "^1.3.33"
}
npm install @angular/core --save
// node_modules/@types
backbone
jquery
underscore