Typescript: Specify type in object declaration -


var = {     b:null,  } 

i want specify type of a.b (num:number) => void while still setting null.

is possible without using class or interface?

this should work:

let = {   b: <(number) => void> null }; 

or can use type declaration make special function explicit:

declare type myfun = (number) => void; let = {   b: <myfun> null }; 

although it's not necessary, tend make use of type declarations in code when there function has semantics not caught in type signature, can specified in name.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -