TypeScript any vs Object -


i looking @ typescript code , noticed use

interface blablabla {     field: object;  } 

what benefit of using object vs any, in

interface blablabla {    field: any;  } 

object more restrictive any. is:

interface myinterface {      b: object; }  var foo = (a : myinterface) => alert(a.b.nomethod()); 

will not compile because object not have nomethod() function. if use any in interface instead of object compile.

so in short, any can (you can call method etc on without compilation errors). if explicitly use object able use methods etc defined on object class.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -