Typescript interface with void method - not reporting error -


why compiler not complain below code? interface has 1 method void. class implements interface signature not same, still compiler not complain;

interface myinterface {   getmethod() : void; }  class myclass implements myinterface {                  getmethod()  {     return "return string";   } }  var myobj = new myclass()  var strvar = myobj.getmethod(); 

why compiler not complain

the way think types in typescript types minimal information satisfy interface. long covers minimum typing ok it.

so in example above have implemented function name takes in no parameters , did @ least implementation returns nothing.

as being able assign variable outside... if return nothing function return of function undefined

the reason why thinking of typing in typescript minimal fulfill contract because type checking 100% optional.


Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -