Check out a free preview of the full Production-Grade TypeScript course:
The "Enabling Stricter Settings" Lesson is part of the full, Production-Grade TypeScript course featured in this preview video. Here's what you'd learn in this lesson:

Mike enables the noUnusedLocals and noImplicitReturns rules in the tsconfig.json file, and recompiles the project.

Get Unlimited Access Now

Transcript from the "Enabling Stricter Settings" Lesson

>> Let's start making our way to step three and this is gonna get a little bit more interesting. So I want to close off my source files and the way we begin step 3 is changing our compiler settings. So in the revised process, we're going to call this step 3.1, all we're doing is we're opting into strict mode.

[00:00:27] So we're gonna find strict, we commented it out, now we're uncommenting it and let's see where we are. We're gonna see if parcel surfaces errors to us. Maybe not. Let's see if TSC does the same thing. All right, it actually turns out we already work with strict mode enabled.

[00:01:04] And that means, we're not using any weird function bind stuff, that this is not that big of a shock. So we can proceed to Step 3.2, right? And this is where we start turning on the even more strict mode. Where we will do things like noUnusedLocals, true, noUnusedParameters, true.

[00:01:38] So that one wasn't even in the notes, but it's worth adding, noUnused, or noImplicitReturns, true. And if you find that this is too much you could even do individual passes with these things. And I would say it's necessary, so I'm thinking about the big app at LinkedIn. The one that you know of as, it's about 115,000 lines of JavaScript code.

[00:02:14] We would definitely wanna do this one at a time, and they would be big changes. But the whole point is you can use some discretion here, you have the ability to decide what's best for your app. What's this one? forceConsistent, I don't need to worry about this one because I don't have any file names that collide, but Gosh, who came up with that name?

[00:02:53] [LAUGH] okay, so this is what I've stated as 3.2 even more strict, let's see if we pass now [LAUGH] I give up on that one. It's already true, I must have misspelled stuff, it's file names, not file name. All right, but I think that TypeScript gave up because my config file was invalid, so I don't believe that it's error free.

[00:03:35] Now I do, cool. Okay, so actually we're in a good spot now, but you could imagine how I could still have some implicit returns hanging around. This would be telling me about this kind of thing.