mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
TypeScript language support
Signed-off-by: PulsarBlow <pulsarblow@gmail.com>
This commit is contained in:
28
samples/TypeScript/classes.ts
Normal file
28
samples/TypeScript/classes.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
class Animal {
|
||||
constructor(public name) { }
|
||||
move(meters) {
|
||||
alert(this.name + " moved " + meters + "m.");
|
||||
}
|
||||
}
|
||||
|
||||
class Snake extends Animal {
|
||||
constructor(name) { super(name); }
|
||||
move() {
|
||||
alert("Slithering...");
|
||||
super.move(5);
|
||||
}
|
||||
}
|
||||
|
||||
class Horse extends Animal {
|
||||
constructor(name) { super(name); }
|
||||
move() {
|
||||
alert("Galloping...");
|
||||
super.move(45);
|
||||
}
|
||||
}
|
||||
|
||||
var sam = new Snake("Sammy the Python")
|
||||
var tom: Animal = new Horse("Tommy the Palomino")
|
||||
|
||||
sam.move()
|
||||
tom.move(34)
|
||||
Reference in New Issue
Block a user