From 67730b4e0b3100a7a6df925ef28606b71aa30a43 Mon Sep 17 00:00:00 2001 From: Bradley Kemp Date: Fri, 19 Oct 2018 13:55:51 +0100 Subject: Add example of "implements" keyword --- typescript.html.markdown | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'typescript.html.markdown') diff --git a/typescript.html.markdown b/typescript.html.markdown index db6579e2..9158f123 100644 --- a/typescript.html.markdown +++ b/typescript.html.markdown @@ -113,6 +113,13 @@ class Point { 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 p2 = new Point(25); //y will be 0 -- cgit v1.2.3