-
Notifications
You must be signed in to change notification settings - Fork 0
/
basic.ts
38 lines (27 loc) · 806 Bytes
/
basic.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
import { Animal, Car, Cat, Golfer } from "./class";
import { fn } from "./function";
import { Shapes } from "./namespace";
import polygons = Shapes.Polygons;
import { doSomething } from "./no-type";
import { NameOrResolver } from "./type";
{
//tuple
const john: [string, number] = ['John', 30];
let kevin: [string, number?];
let tom: [string, number] = ['Tom', 25];
tom.push('male');
let animal = new Animal('Jack');
let cat = new Cat('Tom');
{
let x = 123;
let y = { x: 0, y: 1 };
type A = typeof x; // number
type B = typeof y; // { x: number, y: number }
}
// No error!
let w: Car = new Golfer();
//No error!
fn({ k: 10 });
let sq = new polygons.Square();
let resolve: NameOrResolver;
}