Skip to content

Instantly share code, notes, and snippets.

@pparadis
Created February 15, 2013 01:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pparadis/4957959 to your computer and use it in GitHub Desktop.
Save pparadis/4957959 to your computer and use it in GitHub Desktop.
Exemple par défaut pour TypeScript
// Interface
interface IPoint {
getDist(): number;
}
// Module
module Shapes {
// Class
export class Point implements IPoint {
// Constructor
constructor (public x: number, public y: number) { }
// Instance member
getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); }
// Static member
static origin = new Point(0, 0);
}
}
// Local variables
var p: IPoint = new Shapes.Point(3, 4);
var dist = p.getDist();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment