Content mappers: composite projects report TS6307 for supplemental virtual outputs
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- go, typescript
- Domain
- compilers
Research direction
Start in program.go at verifyCompilerOptions, especially the rootPaths loop that reports TS6307, and reproduce the failure with the content mapper setup and tsc --runExternalCode -p lib --pretty false. Done means supplemental virtual files belonging to a listed source no longer trigger TS6307, while composite project builds and referenced-project checks still pass.
Written by the indexing model from the issue text.
Description
🔎 Search Terms
content mappersupplementalcompositeTS6307Supplemental virtual file produced by the content mapperis not listed within the file list of project
🕗 Version & Regression Information
7.1.0-dev.20260918.1and7.1.0-dev.20260919.1(@typescript/typescript-darwin-x64), macOS 26.6 x64- Content mappers are new in 7.1, so no earlier version to compare against
⏯ Playground Link
n/a (needs a content mapper)
💻 Code
A content mapper that returns a supplemental output makes every composite project fail with TS6307, because the supplemental virtual file (greet.foo.0.mts below) is never part of the project's file list. There is no files or include value that can list it: include globs are matched against the disk, and naming it in files gives TS6053 (file not found). Since referenced projects must be composite, a mapper that uses supplemental outputs cannot be used in a tsc --build graph at all.
Minimal mapper (node_modules/foo-mapper), no dependencies. It treats .foo files as plain TypeScript and returns one supplemental .mts output per file (the real use case is a <script> block inside a single-file component):
node_modules/foo-mapper/package.json
{
"name": "foo-mapper",
"version": "0.0.0",
"type": "module",
"typescript": { "contentMapper": { "exec": ["node", "mapper.mjs"] } }
}
node_modules/foo-mapper/mapper.mjs
let buffered = '';
process.stdin.setEncoding('utf8');
process.stdin.on('data', (chunk) => {
buffered += chunk;
for (;;) {
const end = buffered.indexOf('\r\n\r\n');
if (end < 0) return;
const length = Number(/Content-Length:\s*(\d+)/i.exec(buffered.slice(0, end))[1]);
if (buffered.length < end + 4 + length) return;
const message = JSON.parse(buffered.slice(end + 4, end + 4 + length));
buffered = buffered.slice(end + 4 + length);
if (message.id == null) continue;
let result = null;
if (message.method === 'initialize') result = { positionEncoding: 'utf-16', diagnosticSource: 'foo' };
if (message.method === 'openProject') result = {};
if (message.method === 'transform') {
const { content } = message.params;
result = {
text: content,
extension: '.ts',
mappings: [[0, content.length, 0, content.length, 0, 0]],
supplemental: [{ text: 'export {};\n', extension: '.mts', mappings: [] }],
};
}
const body = JSON.stringify({ jsonrpc: '2.0', id: message.id, result });
process.stdout.write(`Content-Length: ${Buffer.byteLength(body)}\r\n\r\n${body}`);
}
});
process.stdin.on('end', () => process.exit(0));
lib/tsconfig.json
{
"contentMappers": [{ "package": "foo-mapper", "extensions": [".foo"] }],
"compilerOptions": {
"composite": true,
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "dist",
"rootDir": ".",
"module": "esnext",
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"strict": true,
"types": []
},
"include": ["index.ts", "*.foo"]
}
lib/greet.foo
export function greet(name: string): string {
return `hello ${name}`;
}
lib/index.ts
export { greet } from './greet.foo';
Run:
tsc --runExternalCode -p lib --pretty false
🙁 Actual behavior
error TS6307: File '/repro/lib/greet.foo.0.mts' is not listed within the file list of project '/repro/lib/tsconfig.json'. Projects must list all files or use an 'include' pattern.
The file is in the program because:
Supplemental virtual file produced by the content mapper for file '/repro/lib/greet.foo'.
Exit code 2. tsc --build of a project that references lib reports the same error. Variations that do not help:
"include": ["index.ts", "*.foo", "*.foo.*.mts"]: same TS6307 (the glob is matched against the disk, where the virtual file does not exist)"files": ["index.ts", "greet.foo", "greet.foo.0.mts"]:error TS6053: File '/repro/lib/greet.foo.0.mts' not found."composite": false: emitsdist/greet.d.foo.ts,dist/greet.foo.0.d.mtsanddist/index.d.tswithout errors, but a non-composite project cannot be referenced (TS6306)
🙂 Expected behavior
No TS6307. A supplemental output belongs to its original file: if greet.foo is a root file of the project, greet.foo.0.mts should count as listed too. In program.go the composite check (verifyCompilerOptions, the rootPaths loop that reports File_0_is_not_listed_within_the_file_list_of_project_1_...) could skip files whose CanonicalSourceFile() is set, or check rootPaths against file.OriginalFileName() instead of file.FileName().
Additional information about the issue
Found while building the .tsrx content mapper for TSRX (tsrx-org/tsrx#41); the repro above is the same shape without the framework. Tested on 7.1.0-dev.20260918.1 and 7.1.0-dev.20260919.1.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.4k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/TypeScript
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
microsoft/TypeScript#64322 · 2 comments · 1 reaction · 2 assignees ·
-
Possible Improvement
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/TypeScript#64278 · 1 comment · 1 reaction ·
-
Docs
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
microsoft/TypeScript#64118 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
microsoft/TypeScript#64094 ·
-
Docs
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
microsoft/TypeScript#63959 · 5 comments ·
All issues in microsoft/TypeScript
Similar issues
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
githubnext/gh-aw-cao#13143 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
blinklabs-io/bursa#904 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
yanet-platform/ipfw-go#129 ·
-
bug confmap/provider/googlesecretmanagerprovider needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
open-telemetry/opentelemetry-collector-contrib#51273 · 2 comments ·
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100