在VS代码管理器中,我想隐藏TypeScript编译期间生成的文件。
当具有my-file.ts
时,生成的文件可以是:
my-file.js
my-file.js.map
my-file.d.ts
隐藏前两个很容易,我需要在VS代码的settings.json
中这样做:
{
"files.exclude": {
"**/*.js.map": true,
"**/*.js": { "when": "$(basename).ts" }
}
}
但是第三个呢?我尝试过这个,但它隐藏了所有.d.ts
文件,即使是不是从.ts
文件生成的独立文件。
{
"files.exclude": {
"**/*.d.ts": { "when": "$(basename).ts", "__MY_PROBLEM": "It hides all .d.ts files" }
}
}
有没有建议只隐藏那些由同名.ts
文件生成的.d.ts
文件?
您可以用declaration:false
关闭.d.ts
发射或发射它们进入一个单独的目录:
// tsconfig.json
"compilerOptions": {
"declaration": true,
"declarationDir": "./types" // configure the root directory for where declaration files are emitted
对于另一个;隐藏";从v1.64开始生成的文件,请参阅https://stackoverflow.com/a/70748584/836330.
Explorer > Experimental > File Nesting: Patterns
设置如下:
*.ts
$(capture).js, $(capture).js.map, $(capture).d.ts
我认为不可能隐藏与*.ts
文件关联的*.d.ts
文件。
请参阅https://github.com/microsoft/vscode/issues/4642一些人报告说这是有效的:
"**/*.map": {
"when": "$(basename)"
}
隐藏*.js.map
文件,但我无法获得
"**/*.ts": {
"when": "$(basename)"
}
做任何事情。也许你会有更好的运气。
另请参阅https://github.com/microsoft/vscode/issues/59368不成功的
而且https://github.com/microsoft/vscode/issues/40850谈到了所有CCD_ 18文件都被排除在外的事实。关闭为";超出范围";。但你可以投赞成票。
我在vs代码上使用Explorer Exclude插件。它负责.d.ts文件、.d.ts.map文件以及您要添加的其他文件。