therefore, when the calling script calls this file...
# general
o
therefore, when the calling script calls this file.... it will run the loop?
w
Yep - as long as you import this file, all the code in it will run.
c
Programming is confusing lol 🙂
r
Programming is hard 🙂
o
well it's very confusing for me... :-$
🙂
g
There’s actually a small gotcha in TypeScript. When you import something like this:
import something from './something'
but don’t actually use any of the imported symbols in the file where you import it (i.e. in this case the symbol is
something
) or you’re only importing a type, but not a value, the generated runtime code will not load the module, even if you have specified the import. This is kind of an implicit dead code / unused import removal. If you want to import a file just for it’s side-effects, without using any of it’s exported symbols, you have to write simply:
import './something'
. This will always load the module. Here’s a bit more info on that behaviour: https://github.com/Microsoft/TypeScript/wiki/FAQ#why-are-imports-being-elided-in-my-emit
👍 2