Skip to content

Instantly share code, notes, and snippets.

@Nijhazer
Nijhazer / bawts-01.js
Created December 2, 2015 03:14
Building Applications with TypeScript - Snippet 01
var TaskManager = {
getTask: function(id) {
// issue an API request to fetch this task
}
};
@Nijhazer
Nijhazer / bawts-02.js
Created December 2, 2015 03:15
Building Applications with TypeScript - Snippet 02
var myTask = TaskManager.getTask(1);
@Nijhazer
Nijhazer / bawts-03.js
Created December 2, 2015 03:16
Building Applications with TypeScript - Snippet 03
var myTask = TaskManager.getTask("1");
@Nijhazer
Nijhazer / bawts-04.js
Created December 2, 2015 03:17
Building Applications with TypeScript - Snippet 04
var TaskManager = {
getTask: function(id) {
id = parseInt(id);
// issue an API request to fetch this task
}
};
@Nijhazer
Nijhazer / bawts-05.js
Created December 2, 2015 03:18
Building Applications with TypeScript - Snippet 05
var TaskManager = {
getTask: function(id: number) {
// issue an API request to fetch this task
}
};
@Nijhazer
Nijhazer / bawts-06.js
Created December 2, 2015 03:18
Building Applications with TypeScript - Snippet 06
APIManager.configure({
baseURL: 'http://localhost'
});
@Nijhazer
Nijhazer / bawts-07.js
Created December 2, 2015 03:19
Building Applications with TypeScript - Snippet 07
interface IAPIConfiguration {
url: string;
}
var APIManager = {
configure: function(configuration : IAPIConfiguration) {
}
};
@Nijhazer
Nijhazer / bawts-08.js
Created December 2, 2015 03:20
Building Applications with TypeScript - Snippet 08
export class Task {
public name: string;
public active: boolean;
public render() : string {
if (this.active) {
return '[Inactive] ' + this.name;
}
return this.name;
}
@Nijhazer
Nijhazer / bawts-09.sh
Created December 2, 2015 03:21
Building Applications with TypeScript - Snippet 09
tsc --module commonjs task.ts
@Nijhazer
Nijhazer / bawts-10.sh
Created December 2, 2015 03:22
Building Applications with TypeScript - Snippet 08
tsc --module amd task.ts