Repository navigation
Description
π Search Terms
getFileMatcherPatterns, getSupportedExtensions, include, exclude, config file coverage, getDefaultProjectForFile, typescript/sync
β Viability Checklist
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
β Suggestion
Add a public way to ask whether a config's files/include/exclude covers a path. It should also work for paths created after the config was parsed. Either of these would work:
- A high-level query, e.g.
api.isFileCoveredByConfig(configFileName, fileName). It would apply TypeScript's own wildcard, default-include, extension and case-sensitivity rules, including specs inherited throughextends. - The lower-level pieces TS 6 had internally: the matcher patterns from
getFileMatcherPatternsand the extension list fromgetSupportedExtensions(options).
π Motivating Example
In TS 6 we pair getParsedCommandLineOfConfigFile with those two internals. In 7.1 beta, api.parseConfigFile() covers the parsing, but nothing replaces the internals.
snapshot.getDefaultProjectForFile() doesn't fill the gap. It reports which project has loaded a file, not whether the config covers it. It also misses new files (tested on 7.1.0-beta and 7.1.0-dev.20261111.1):
// tsconfig.json: { "include": ["src/**/*"] }
const s1 = api.createSnapshot({ openProjects: [config] });
// ...create src/new.ts on disk
const s2 = s1.update({ fileNotifications: { created: [newFile] } });
s2.getDefaultProjectForFile(newFile); // undefined; found only after invalidateAll or a fresh snapshotπ» Use Cases
- supi routes files to their tsconfig in an LSP client for coding agents, including files the agent has just created.
- Re-implementing TypeScript's glob semantics on the client risks diverging from
tsc. - Workaround: we keep TS 6 as a runtime dependency only for these internals.
Related: #64709, #64749, #64610, #65348
Drafted with an AI coding agent; reviewed and verified by me.
Activity
andrewbranch commentedon Nov 11, 2026
Though not the central point of the issue, the problem with your example code is that
s1.updateis missingensurePrograms: true.mrclrchtr commentedon Nov 12, 2026
Thanks, confirmed: with
ensurePrograms: truethe created file resolves, so the example in the description is wrong on that point.The gap remains for config coverage:
src/future.tsunder"include": ["src/**/*"]) returnsundefinedincludethat's only imported (other/dep.ts) returns the project, since it's in the programWe need "would this config's
files/include/excludematch this path?", which is whatgetFileMatcherPatterns+getSupportedExtensionsgave us in TS 6.