0

Please consider my previous post A Function that can be an Object in JavaScript ? [duplicate] which was marked as duplicate and it makes perfect sense. I was asking how I could resolve that :

function foo () {}
foo.bar = function () {}

because during testing this didn't work, but while it would make pure sense in commonJS, my issue is TypeScript specific. If I write the snippet above in my editor and try to compile, Typescript will tell :

Property 'bar' does not exist on type '() => void'.

How should I write to give a function property a function ?

vdegenne
  • 12,272
  • 14
  • 80
  • 106
  • 1
    You have some options [here](https://stackoverflow.com/questions/12766528/build-a-function-object-with-properties-in-typescript). Check answers below the accepted one – Aleksey L. Apr 04 '18 at 05:49
  • 1
    check this out - https://www.reddit.com/r/typescript/comments/6cljb3/is_it_possible_to_add_methods_to_functions_in/ – khawar jamil Apr 04 '18 at 05:53

0 Answers0