From c2022eefbb36322d2e07ea6df27086731646d192 Mon Sep 17 00:00:00 2001 From: Patryk Buda Date: Sat, 3 Nov 2018 19:34:13 +0000 Subject: [PATCH] Implementation of an Interface (#20815) * Implementation of an Interface * minor updates --- guide/english/typescript/interfaces/index.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/guide/english/typescript/interfaces/index.md b/guide/english/typescript/interfaces/index.md index b0717a4c58..532c40c0fe 100644 --- a/guide/english/typescript/interfaces/index.md +++ b/guide/english/typescript/interfaces/index.md @@ -26,4 +26,19 @@ Interfaces can contain optional parameters interface User = { email?: string; } -``` \ No newline at end of file +``` + +We can also use interfaces as the Promises to our classes. For example, when declaring names of methods in our interface they need to be in our implementation otherwise we will get an exception. +Example: +```typescript +interface Login { + login(): boolean; +} +class LoginImplementation implements Login { + login(): boolean { + //Here would be our implementation of login class.In this case it returns an Error. + throw new Error("Method not implemented."); + } + +} +```