Skip to content
This repository has been archived by the owner on Dec 1, 2019. It is now read-only.

Commit

Permalink
fix(host): add ad-hoc files lookup to support typings scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Panferov committed Dec 2, 2015
1 parent 0fa2adf commit b768c24
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,17 @@ export class Host implements ts.LanguageServiceHost {

getScriptSnapshot(fileName) {
let file = this.state.getFile(fileName);
if (file) {
return this.state.ts.ScriptSnapshot.fromString(file.text);
if (!file) {
try {
this.state.readFileAndUpdateSync(fileName);
file = this.state.getFile(fileName);
}
catch (e) {
return;
}
}

return this.state.ts.ScriptSnapshot.fromString(file.text);
}

getCurrentDirectory() {
Expand Down Expand Up @@ -293,9 +301,9 @@ export class State {
return changed
}

addFile(fileName: string, text: string): void {
addFile(fileName: string, text: string): IFile {
fileName = this.normalizePath(fileName);
this.files[fileName] = {
return this.files[fileName] = {
text: text,
version: 0
}
Expand Down

0 comments on commit b768c24

Please sign in to comment.