0

Is it possible to add a function to the global namespace in TypeScript?

I have a function that I use so ubiquitously that is very much tied to a certain programming style that I don't want have an import in every file that uses it.

I thought I was close by defining this function in a file without any exports. The compiler did not complain, but at runtime the function was not found.

Corno
  • 5,448
  • 4
  • 25
  • 41
  • Does one of these answer your question? https://stackoverflow.com/questions/47736473/how-to-define-global-function-in-typescript https://stackoverflow.com/questions/47971729/declaring-global-functions-in-a-typescript-module https://stackoverflow.com/questions/63652241/define-global-function-in-module https://stackoverflow.com/questions/47234400/typescript-global-function ? – Alex Wayne Jun 29 '22 at 23:37
  • The first one did. I did a bad job in searching for an answer first. Thanks – Corno Jul 01 '22 at 02:44

0 Answers0