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
Post a Comment