Skip to content

Commit 0c7e6aa

Browse files
author
roman.vasilev
committed
Fix: Update method, fileContent is optinal
1 parent 84857f7 commit 0c7e6aa

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,15 @@ export function createService({ compilerOptions, configFile }: createServiceOpti
9292
const service = ts.createLanguageService(servicesHost, ts.createDocumentRegistry());
9393

9494
return {
95-
update({ fileName, fileContent }: { fileName: string, fileContent: string }) {
95+
update({ fileName, fileContent }: { fileName: string, fileContent?: string }) {
9696
fileName = fileName.replace(/\\/g, '/');
9797
let fileRef = files[fileName];
9898
if (!fileRef) {
9999
files[fileName] = fileRef = { version: 0, snapshot: undefined };
100100
}
101+
if (fileContent === undefined) {
102+
fileContent = readFileSync(fileName, 'utf8');
103+
}
101104
fileRef.snapshot = ts.ScriptSnapshot.fromString(fileContent);
102105
fileRef.version++;
103106

0 commit comments

Comments
 (0)