Skip to content

Commit

Permalink
Fix: Update method, fileContent is optinal
Browse files Browse the repository at this point in the history
  • Loading branch information
roman.vasilev committed Jun 30, 2018
1 parent 84857f7 commit 0c7e6aa
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,15 @@ export function createService({ compilerOptions, configFile }: createServiceOpti
const service = ts.createLanguageService(servicesHost, ts.createDocumentRegistry());

return {
update({ fileName, fileContent }: { fileName: string, fileContent: string }) {
update({ fileName, fileContent }: { fileName: string, fileContent?: string }) {
fileName = fileName.replace(/\\/g, '/');
let fileRef = files[fileName];
if (!fileRef) {
files[fileName] = fileRef = { version: 0, snapshot: undefined };
}
if (fileContent === undefined) {
fileContent = readFileSync(fileName, 'utf8');
}
fileRef.snapshot = ts.ScriptSnapshot.fromString(fileContent);
fileRef.version++;

Expand Down

0 comments on commit 0c7e6aa

Please sign in to comment.