mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Add example of "implements" keyword
This commit is contained in:
parent
9e2bd7c11b
commit
67730b4e0b
@ -113,6 +113,13 @@ class Point {
|
|||||||
static origin = new Point(0, 0);
|
static origin = new Point(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Classes can be explicitly marked as implementing an interface.
|
||||||
|
// Any missing properties will then cause an error at compile-time.
|
||||||
|
class PointPerson implements Person {
|
||||||
|
name: string
|
||||||
|
move() {}
|
||||||
|
}
|
||||||
|
|
||||||
let p1 = new Point(10, 20);
|
let p1 = new Point(10, 20);
|
||||||
let p2 = new Point(25); //y will be 0
|
let p2 = new Point(25); //y will be 0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user