Project-Wide Type Checking with jsconfig.json
You'll learn how to enable type checking across your entire JavaScript project without adding @ts-check to every single file.
The Challenge of Per-File Type Checking
Until now, you've been adding // @ts-check at the top of individual files to enable TypeScript's type checker. This works, but it's tedious and error-prone—new files might accidentally skip the comment, leaving gaps in your type safety coverage.
Enter jsconfig.json
Think of jsconfig.json as your project's master control panel for JavaScript tooling. Instead of opting individual files into type checking, you can flip a single switch that applies to your entire codebase.
Create a jsconfig.json file in your project root:
{
"compilerOptions": {
"checkJs": true
}
}
That's it! Now every JavaScript file in your project gets type-checked automatically—no per-file comments needed.
What This Means in Practice
With checkJs: true, the TypeScript language server (the engine behind VS Code's IntelliSense) will:
- Infer types throughout your code
- Flag type mismatches and inconsistencies
- Respect your JSDoc annotations
- Surface errors in the editor without requiring a build step
You can still exclude specific files using // @ts-nocheck if needed, but the default becomes "check everything."
The Analogy
It's like setting your building's default thermostat instead of adjusting each room individually. You get consistent coverage with far less effort, and individual rooms (files) can still override when necessary.
Key Takeaway: Setting "checkJs": true in jsconfig.json enables project-wide type checking for all JavaScript files, replacing the need for per-file @ts-check comments.