Import types
There are times where we need to write a global script that does not use modules. This means that we do not have the ability to use the import keyword in our code. Note that the import keyword does two things for us. Firstly, it imports the declaration file for a module, so that we have access to the type signatures of exported variables and functions through our development environment. Secondly, at runtime, it will load the JavaScript file for us to use. When we are not using modules, we need to specify each of the JavaScript files within our HTML file, as seen earlier in the chapter.
Unfortunately, when we attempt to write code without modules, we lose the ability for the development environment to use the declaration files. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access