I am working on a typescript project in Visual Studio code and would like to hide the .js.map
(and maybe even the .js
) files from appearing in the
1. Go to preferences > settings
2. Click on "Edit on settings.json" (It's on the bottom of the image)
3. Update the object json as you can see in the image. Then save your changes Ctrl + S
and that's all.
"files.exclude": {
"**/*.js": {"when": "$(basename).ts"}
}
From the official doc:
to exclude JavaScript files generated from both .ts and .tsx source files, use this expression:
"**/*.js": { "when": "$(basename).ts" },
"**/**.js": { "when": "$(basename).tsx" }
This is a bit of a trick. The search glob pattern is used as a key. The settings above use two different glob patterns to provide two unique keys but the search will still match the same files.
UPDATE 10/3/2017: with this trick we have a problem with "search in folder". Please see the issue
I really don't know how this is implemented but for hiding .js
files works:
"**/*.js": {"when": "$(basename).ts"}
For hiding .js.map
files works:
"**/*.js.map": {"when": "$(basename)"}
John Papa Twitter LINK says use the following:
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
"**/*.js" : {
"when": "$(basename).ts"
},
"**/*.js.map": {
"when": "$(basename)"
}
}
There is still no official solution for excluding a file glob based on two different conditions. See this issue.
There is a workaround though, to define two different glob patterns which target the same files:
{
"files.exclude": {
"**/*.js": { "when": "$(basename).ts"},
"**/*?.js": { "when": "$(basename).tsx"}
}
}
I found this, If you have standard JS files then these will be hidden too which may not always be what you want. Perhaps this is better as it only hides JS files that match TS files...
{
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
"**/*.js.map": true,
"**/*.js": {"when": "$(basename).ts"}
}
}