代码搜索:如何排除TypeScript类型定义文件?以createPerformanceMarker为例
The issue here is that Azure DevOps Code Search treats .d.ts files as matching ext:ts (since the final file extension suffix is ts). Using ext:ts NOT ext:d.ts won't work because .d.ts doesn't register as having an extension of d.ts in the search engine's logic—it only looks at the last segment after the final dot.
Here are two reliable ways to exclude .d.ts files while searching for your function:
Combine
ext:tswith a filename exclusion
Use this search query to target.tsfiles and explicitly exclude any file ending with.d.ts:createPerformanceMarker ext:ts AND NOT filename:*.d.tsDirectly target non-declaration
.tsfiles
If you prefer a more concise approach, you can use filename patterns to specify only regular.tsfiles (excluding.d.ts):createPerformanceMarker filename:*.ts NOT filename:*.d.ts
Both of these queries leverage the filename: parameter, which lets you match or exclude specific filename patterns—this is the key to distinguishing between regular TypeScript files and type declaration files in Azure DevOps Code Search.
内容的提问来源于stack exchange,提问作者Ondrej Svejdar

