Question
I am working on a TypeScript project in Visual Studio Code and want to hide generated .js.map files, and possibly generated .js files, from the File Explorer.
Is it possible to configure VS Code so that only .ts source files are shown while generated JavaScript and source map files are hidden?
Short Answer
You will learn how Visual Studio Code's files.exclude setting hides matching files in the Explorer without deleting them. You will also learn glob patterns for generated TypeScript output, workspace-specific configuration, and when to use search.exclude separately.
Concept
Visual Studio Code can hide files and folders in its Explorer through the files.exclude setting. This is useful when your project contains generated output that you normally do not need to edit directly.
TypeScript commonly produces files such as:
app.ts— the source file you editapp.js— compiled JavaScript outputapp.js.map— a source map used by debuggers to connect JavaScript back to TypeScript
Hiding generated files keeps the Explorer focused on source code. It does not delete files, stop TypeScript from compiling them, or prevent Node.js and browsers from using them.
Use files.exclude for the Explorer. If you also want to prevent generated files from appearing in global search results, configure search.exclude too.
Mental Model
Think of the VS Code Explorer as a bookshelf and files.exclude as a label telling VS Code which books should stay behind a curtain.
The files are still on the shelf: TypeScript can generate them, Git can track them, and your application can run them. The Explorer simply does not display the files matching your rule.
Syntax and Examples
Add exclusion patterns to VS Code settings.
For a project-specific rule, create or edit .vscode/settings.json in the project root:
{
"files.exclude": {
"**/*.js": true,
"**/*.js.map": true
}
}
**/ means “in this folder or any nested folder,” and *.js means “a filename ending in .js.”
The first rule hides JavaScript files and the second hides source map files. In practice, **/*.js does not match file.js.map, because that filename ends with .map, so both patterns are needed.
If you only want to hide source maps, use:
{
"files.exclude": {
"**/*.js.map"
Step by Step Execution
Suppose the project contains this structure:
src/
calculator.ts
calculator.js
calculator.js.map
helpers/
format.ts
format.js
format.js.map
With this setting:
{
"files.exclude": {
"**/*.js": true,
"**/*.js.map": true
}
}
VS Code evaluates each path:
src/calculator.tsdoes not match either pattern, so it remains visible.src/calculator.jsmatches**/*.js, so it is hidden.src/calculator.js.mapmatches**/*.js.map, so it is hidden.src/helpers/format.tsremains visible.- The generated files inside
helpersare also hidden because**/includes nested directories.
The result is an Explorer that shows the TypeScript source files while leaving generated output on disk.
Real World Use Cases
Common reasons to hide generated files include:
- TypeScript applications: Hide emitted
.js,.js.map, and declaration files while editing.tsfiles. - Frontend builds: Hide generated bundles such as
dist/app.jswhen source files live elsewhere. - Code generation: Hide files created from API schemas, ORM tools, or protocol definitions.
- Coverage and reports: Hide temporary coverage output and generated test reports.
- Large repositories: Reduce noise from tool caches and build artifacts so developers can navigate source code faster.
If generated output is placed in a dedicated folder such as dist/, hiding that folder is often clearer than hiding each extension.
Real Codebase Usage
In real projects, developers usually combine editor visibility rules with a clean build layout.
A common TypeScript configuration writes output to dist/:
{
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"sourceMap": true
}
}
Then the workspace can hide the whole build folder:
{
"files.exclude": {
"**/dist": true
},
"search.exclude": {
"**/dist": true
}
}
Keeping generated output in avoids mixing source and build files in .
Common Mistakes
Expecting hidden files to be deleted
files.exclude only changes Explorer visibility. It does not remove files.
{
"files.exclude": {
"**/*.js": true
}
}
The .js files still exist and may still be committed by Git unless .gitignore excludes them.
Using files.exclude to control search results
Explorer exclusions and search exclusions are separate settings. Add search.exclude when needed:
{
"files.exclude": {
"**/*.js.map": true
},
"search.exclude": {
"**/*.js.map":
Comparisons
| Option | What it changes | Best use |
|---|---|---|
files.exclude | What appears in the VS Code Explorer | Hide generated files from the sidebar |
search.exclude | What VS Code searches by default | Avoid searching build output and maps |
.gitignore | Which untracked files Git ignores | Prevent generated files from being added to Git |
outDir in tsconfig.json | Where TypeScript writes compiled output | Keep source and build output separate |
| File nesting | How related visible files are grouped | Keep .ts, .js, and .map together rather than hide them |
Cheat Sheet
{
"files.exclude": {
"**/*.js.map": true,
"**/*.js": true
}
}
- Put project-specific settings in
.vscode/settings.json. **/matches files at any folder depth.*.jsmatches JavaScript files;*.js.mapmatches source maps.- Hidden files remain on disk and are still usable by tools.
- Use
search.excludeseparately to omit files from search. - Prefer hiding
dist/when all build output is stored there. - Use
.gitignoreto control Git, not Explorer visibility.
FAQ
How do I hide .js.map files in VS Code?
Add this to Settings JSON or .vscode/settings.json:
{
"files.exclude": {
"**/*.js.map": true
}
}
Can VS Code show only TypeScript files in the Explorer?
You can hide known non-TypeScript generated file types with files.exclude, such as .js and .js.map. There is no need to delete those files; they simply become invisible in the Explorer.
Does files.exclude delete or ignore files?
No. It only hides matching paths in the VS Code Explorer. Use .gitignore to tell Git to ignore files.
Why do .js.map files still appear in search?
files.exclude controls Explorer visibility, not search. Add the same pattern under search.exclude.
Should I hide files in a TypeScript project?
Mini Project
Description
Configure a small TypeScript workspace so the Explorer focuses on source files while generated JavaScript output remains available for running and debugging.
Goal
Create workspace settings that hide generated JavaScript and source map files from the VS Code Explorer and search results.
Requirements
Requirement 1
Keep learning
Related questions
@Directive vs @Component in Angular: Differences, Use Cases, and When to Use Each
Learn the difference between @Directive and @Component in Angular, including use cases, examples, and when to choose each.
Accessing Input Value from EventTarget in TypeScript
Learn why EventTarget has no value property in TypeScript and safely read values from HTML input events in Angular applications.
Angular (change) vs (ngModelChange): What’s the Difference?
Learn the difference between Angular (change) and (ngModelChange), when each fires, and which one to use in forms and inputs.