Skip to content

API: expose config include/exclude matching and supported extensionsΒ #65443

Open

Description

πŸ” Search Terms

getFileMatcherPatterns, getSupportedExtensions, include, exclude, config file coverage, getDefaultProjectForFile, typescript/sync

βœ… Viability Checklist

⭐ 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:

  1. 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 through extends.
  2. The lower-level pieces TS 6 had internally: the matcher patterns from getFileMatcherPatterns and the extension list from getSupportedExtensions(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

  1. supi routes files to their tsconfig in an LSP client for coding agents, including files the agent has just created.
  2. Re-implementing TypeScript's glob semantics on the client risks diverging from tsc.
  3. 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

  1. andrewbranch commented on Nov 11, 2026

    @andrewbranch
    Member

    Though not the central point of the issue, the problem with your example code is that s1.update is missing ensurePrograms: true.

  2. mrclrchtr commented on Nov 12, 2026

    @mrclrchtr
    Author

    Thanks, confirmed: with ensurePrograms: true the created file resolves, so the example in the description is wrong on that point.

    The gap remains for config coverage:

    • a path that doesn't exist yet (e.g. src/future.ts under "include": ["src/**/*"]) returns undefined
    • a file outside include that's only imported (other/dep.ts) returns the project, since it's in the program

    We need "would this config's files/include/exclude match this path?", which is what getFileMatcherPatterns + getSupportedExtensions gave us in TS 6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions