How to define interface for class in TypeScript?

OPV

I have to specify all actions in interface whitch should be realized in class.

I transfered to TypeScript from PHP.

Creating interfaces in PHP is very easy:

interface iTemplate
{
    public function move($name, $var);

}

Class is:

Class Mover inmpelments iTemplate {
    function move($name, $var){}
}

How to do that in TypeScript? For example, I have class User, that can:

edit profile
see users
etc
Tom Cumming
interface MyInterface {
    editProfile(profileId: number): void;
    seeUsers(): object[];
    etc: string;
}

class MyImplementation implements MyInterface{
    editProfile(profileId: number): void {
        throw 'todo';
    }

    seeUsers(): object[] {
        throw 'todo';
    }

    readonly etc = 'something else'; 
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How define class and interface hierarchy?

From Dev

How can I define a Typescript interface for a function?

From Dev

How can you define a Decorator interface in TypeScript

From Dev

TypeScript Class how to define not prototype class function

From Dev

How to use WinJS.Class.define() in Typescript?

From Dev

How can I define a return type of void for a function in a Typescript interface?

From Java

How can I define an interface for an array of objects with Typescript?

From Dev

How do I define an anonymous generic interface in typescript?

From Dev

How do I define an anonymous generic interface in typescript?

From Dev

How can I create a interface that receives a class, and not a instance of the class in typescript

From Dev

How can I create a interface that receives a class, and not a instance of the class in typescript

From Dev

Define interface object with class implemention

From Dev

Define data type class for interface

From Dev

Writing Typescript interface for a Class

From Dev

TypeScript interface to describe class

From Dev

How to define a singleton javascript class in a typescript declaration file

From Dev

How to define "interface" in js

From Java

How to define Singleton in TypeScript

From Dev

Typescript Interface to define type for my model

From Java

When use a interface or class in Typescript

From Dev

typescript parse json with class and interface

From Dev

TypeScript class with same name as interface

From Dev

Typescript generics extending class and interface

From Dev

TypeScript - Check if Class implements an Interface

From Dev

Class like a type in interface of Typescript

From Dev

Static polymorphism: How to define the interface?

From Dev

Force a class implementing the interface to define a constant

From Dev

How to define class in python?

From Dev

How can I define some functions individually for each interface of my class?

Related Related

  1. 1

    How define class and interface hierarchy?

  2. 2

    How can I define a Typescript interface for a function?

  3. 3

    How can you define a Decorator interface in TypeScript

  4. 4

    TypeScript Class how to define not prototype class function

  5. 5

    How to use WinJS.Class.define() in Typescript?

  6. 6

    How can I define a return type of void for a function in a Typescript interface?

  7. 7

    How can I define an interface for an array of objects with Typescript?

  8. 8

    How do I define an anonymous generic interface in typescript?

  9. 9

    How do I define an anonymous generic interface in typescript?

  10. 10

    How can I create a interface that receives a class, and not a instance of the class in typescript

  11. 11

    How can I create a interface that receives a class, and not a instance of the class in typescript

  12. 12

    Define interface object with class implemention

  13. 13

    Define data type class for interface

  14. 14

    Writing Typescript interface for a Class

  15. 15

    TypeScript interface to describe class

  16. 16

    How to define a singleton javascript class in a typescript declaration file

  17. 17

    How to define "interface" in js

  18. 18

    How to define Singleton in TypeScript

  19. 19

    Typescript Interface to define type for my model

  20. 20

    When use a interface or class in Typescript

  21. 21

    typescript parse json with class and interface

  22. 22

    TypeScript class with same name as interface

  23. 23

    Typescript generics extending class and interface

  24. 24

    TypeScript - Check if Class implements an Interface

  25. 25

    Class like a type in interface of Typescript

  26. 26

    Static polymorphism: How to define the interface?

  27. 27

    Force a class implementing the interface to define a constant

  28. 28

    How to define class in python?

  29. 29

    How can I define some functions individually for each interface of my class?

HotTag

Archive