When function f
is called, it returns bar, so that I can then call bar.baz()
. However, typescript complains that Property baz does not exist on type (selection: any) => () => void
How can I declare the baz property of bar to make this compile?
var f = function foo(){
function bar(selection : any){
}
bar.baz = function(value){
}
return bar
}
(as an aside, I have this code inside an angular2 typescript project and it's very unforgiving. Other typescript projects I've worked on allow you to ignore the typescript errors, but this angular starter project really won't compile so I'm stuck until the typescript issue is resolved)
do you mean this?
interface foo {
(selection: any): void;
baz: (value) => void;
}
var f = function () {
var bar: foo = function (selection: any) {
} as any
bar.baz = function (value) {
}
return bar
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments