Modules Scripts and Declaration Files 7 exercises
Problem

Enforcing Module Usage in TypeScript

In general, frontend applications will use modules instead of scripts.

Consider the following scenario with two files script-1.ts and script-2.ts:

// script-1.ts
const myFunc = () => {
  console.log("Hello!");
};

// script-2.ts
// I can use myFunc without importing it!

// @ts-e
Loading exercise

Transcript

00:00 In general, in your front-end applications, you're gonna be using modules and not scripts. So it would be really good if there was a way to tell TypeScript that everything I do inside this project is a module, not a script. And if I have an accidental script here, let's say I have a script one file and a script two file, it would be great if I could get an error saying

00:19 my func shouldn't be used without being imported. Your job is to try to go into the tsconfig.json for this folder and actually add an option on here that forces TypeScript to say, okay, everything is going to be a module, not a script.

00:38 I will add a link below to the tsconfig option if you get a bit confused or if you get a bit lost, but try and see if you can navigate it yourself. Good luck.