🔎 Search Terms
content mapper supplemental composite TS6307
Supplemental virtual file produced by the content mapper
is not listed within the file list of project
🕗 Version & Regression Information
7.1.0-dev.20260918.1 and 7.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: emits dist/greet.d.foo.ts, dist/greet.foo.0.d.mts and dist/index.d.ts without 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.
🔎 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⏯ Playground Link
n/a (needs a content mapper)
💻 Code
A content mapper that returns a
supplementaloutput makes everycompositeproject fail with TS6307, because the supplemental virtual file (greet.foo.0.mtsbelow) is never part of the project's file list. There is nofilesorincludevalue that can list it:includeglobs are matched against the disk, and naming it infilesgives TS6053 (file not found). Since referenced projects must becomposite, a mapper that uses supplemental outputs cannot be used in atsc --buildgraph at all.Minimal mapper (
node_modules/foo-mapper), no dependencies. It treats.foofiles as plain TypeScript and returns one supplemental.mtsoutput 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.mjslib/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.foolib/index.tsRun:
tsc --runExternalCode -p lib --pretty false🙁 Actual behavior
Exit code 2.
tsc --buildof a project that referenceslibreports 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.foois a root file of the project,greet.foo.0.mtsshould count as listed too. Inprogram.gothe composite check (verifyCompilerOptions, therootPathsloop that reportsFile_0_is_not_listed_within_the_file_list_of_project_1_...) could skip files whoseCanonicalSourceFile()is set, or checkrootPathsagainstfile.OriginalFileName()instead offile.FileName().Additional information about the issue
Found while building the
.tsrxcontent mapper for TSRX (tsrx-org/tsrx#41); the repro above is the same shape without the framework. Tested on7.1.0-dev.20260918.1and7.1.0-dev.20260919.1.