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
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.
Comments