Content mappers: composite projects report TS6307 for supplemental virtual outputs
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 72/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- go, typescript
- Área
- compilers
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
🔎 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.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.4k
- Merge medio
- 1 d 15 h
- PR fusionados (30 d)
- 106
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/TypeScript
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
microsoft/TypeScript#64322 · 2 comentarios · 1 reacción · 2 asignados ·
-
Possible Improvement
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
microsoft/TypeScript#64278 · 1 comentario · 1 reacción ·
-
Docs
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
microsoft/TypeScript#64118 · 1 comentario ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
microsoft/TypeScript#64094 ·
-
Docs
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
microsoft/TypeScript#63959 · 5 comentarios ·
Todos los issues de microsoft/TypeScript
Issues similares
-
Type/Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
OpenNSW/nsw-srilanka#497 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
milvus-io/birdwatcher#545 ·
-
kind/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
kubernetes-sigs/prow#953 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
caddyserver/caddy#8046 ·