-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterfaces.ts
More file actions
49 lines (42 loc) · 1.12 KB
/
interfaces.ts
File metadata and controls
49 lines (42 loc) · 1.12 KB
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
/***** interfaces *****/
// One major difference between type aliases vs interfaces
// are that interfaces are open and type aliases are closed.
// can make properties optional (nullable) by adding a ?
interface Person {
id: number;
prefix?: string;
firstName: string;
middleInitial?: string;
lastName: string;
suffix?: string;
dateOfBirth?: Date;
age?: number;
gender?: string;
ethnicity?: string;
address: Address;
email: string;
phone: string;
}
interface Address {
addressLineOne: string;
addressLineTwo?: string;
addressLineThree?: string;
city: string,
state?: string,
country: string,
postalCode: string;
}
// extending an interface
// export keyword will allow usage outside of the class
export interface SubscriptionMember extends Person {
subscriptionFee: number;
enrollmentDate: Date;
enrollmentStatus: string;
}
// method definition
// export keyword will allow usage outside of the class
// example in implementingInterfaces.ts file
export interface GetSubscriptionMember {
GetSubscriptionMember(): SubscriptionMember
}
export { }