From the course: TypeScript for Node.js Developers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Organizing with modules

Organizing with modules

From the course: TypeScript for Node.js Developers

Start my 1-month free trial

Organizing with modules

- [Instructor] Organizing your code is crucial as your application grows, and we'll explore these tools such as modules and namespacing. First, let me explain the errors we fixed earlier. When you import modules, you need to import only the modules you need and not the entirely library from that module. For example, here we have express and we want to make sure we import specific things. Also, when you export your own modules, like for example, the messenger class we created earlier, you can use the same approach you've been using with ES6 syntax. So if you're not familiar with import, export, when you export, you need to export this way. Default means that this is the only thing that you're exporting from that file. If you export multiple items, then you would remove the default, and then export class Messenger, and then export another class and so on and so forth. So when you need to import them, because we're importing something specific here, we can do this way. If you want to…

Contents