Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/serious-olives-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rnx-kit/typescript-service": patch
---

Projects should use the writeFile set in the LanguageServiceHost to write files
if it is overridden.
5 changes: 4 additions & 1 deletion packages/typescript-service/src/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class Project {
private externalFiles: ExternalFileCache;

private languageService: ts.LanguageService;
private writeFile: (fileName: string, content: string) => void;

constructor(
documentRegistry: ts.DocumentRegistry,
Expand Down Expand Up @@ -93,6 +94,8 @@ export class Project {
if (enhanceLanguageServiceHost) {
enhanceLanguageServiceHost(languageServiceHost);
}
// if someone replaces writeFile when they enhance the language service host, use that for writing
this.writeFile = languageServiceHost.writeFile || ts.sys.writeFile;

this.languageService = ts.createLanguageService(
languageServiceHost,
Expand Down Expand Up @@ -157,7 +160,7 @@ export class Project {
return false;
}
output.outputFiles.forEach((o) => {
ts.sys.writeFile(o.name, o.text);
this.writeFile(o.name, o.text);
});
return true;
}
Expand Down
Loading