-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnippet.ts
72 lines (57 loc) · 1.17 KB
/
snippet.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
let a: string = "test";
console.log(a);
function testLength(a: string, b: number): boolean {
return a.length === b;
}
let b = testLength("test", 4);
console.log(b);
function vanilla(a: string, b: string) {
return a + b;
}
type Mammal = {
legs: number;
tail: boolean;
endangered: boolean;
};
let tiger: Mammal = {
legs: 4,
tail: true,
endangered: true
};
enum BioClass {
"Reptile",
"Mammal"
}
interface Animal {
type: BioClass;
isAquatic(): boolean;
}
interface MammalInterface extends Animal {
legs: number;
tail: boolean;
endangered: boolean;
count(): number;
}
class AnimalClass implements Animal {
private aquatic: boolean;
public type: BioClass;
public isAquatic(): boolean {
return this.aquatic;
}
}
class MammalClass extends AnimalClass implements MammalInterface {
private carnivore: boolean;
public legs: number;
public tail: boolean;
public endangered: boolean;
public extraProperty: boolean;
public count() {
return 3200;
}
public isCarnivore() {
return this.carnivore;
}
}
// properties and methods available on a variable is determined from the type;
let panda = new MammalClass();
panda.count();