microsoft / microsoft/TypeScript
Add native-preview API for capturing .d.ts emit output
@andrewbranch ci sta già lavorando.
Dal 24/6/2026.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
Hey folks, I’ve been experimenting with the native-preview JS API for TS-go API mode, and I’m getting a lot of value from the virtual filesystem callbacks, especially overriding `readFile` for typechecking.
I’m curious whether there are plans to expose declaration emit through this API as well.
Today, as far as I can tell, the JS API can ask for declaration diagnostics, and the CLI can emit `.d.ts` files, but there does not seem to be an API-mode equivalent that lets a JS caller capture emitted `.d.ts` contents while still using the virtual filesystem callbacks.
The use case is an orchestration layer that already supplies source contents through `readFile` callbacks. I want to extend this system to capture generated declaration text for storage/caching without writing to the real filesystem.
Concretely, I’m wondering whether an API roughly like this would be in scope:
```ts
const emittedFiles = new Map();
const api = new API({
fs: {
readFile: (filePath) => {
// Optionally provide source contents from a virtual FS.
},
writeFile: (filePath, content) => {
emittedFiles.set(filePath, content);
},
},
});
await api.emit({
project: "/path/to/tsconfig.json",
fileName: "foo.ts", // optional: omit for whole project
emitOnly: "dts",
compilerOptions: {
declaration: true,
emitDeclarationOnly: true,
noCheck: true,
declarationMap: false,
},
});
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Valutazione
Questa issue non è ancora stata valutata.