I want to use a variable outside a function without using global variable.
After searching, I found this answer working: https://stackoverflow.com/a/8819001
It works perfectly but it raises error in Typescript.
Is there any way to eliminate this error?
You can run this code here and see:
https://www.typescriptlang.org/play?#code/DYUwLgBAZg9jC8AKAlPAfAbwFAVxUkAdgIYC2I8A5ANIAiAQpTnrDAHTEBGAxvCeVgC+WViizcYhAM4xQbYDADmiVhx7IsQA
let foo=()=>{
let name='KDB'
foo.abc=name
}
foo()
console.log(foo.abc)```