-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Restored getSource file fallback implementation
- Loading branch information
roman.vasilev
committed
Aug 26, 2018
1 parent
562bf9b
commit e29755c
Showing
3 changed files
with
23 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as ts from 'typescript'; | ||
|
||
export function getSourceFile(program: ts.Program, fileName: string, sourceText?: string): ts.SourceFile { | ||
if (program !== undefined) { | ||
const sourceFile = program.getSourceFile(fileName); | ||
if (sourceFile) { | ||
return sourceFile; | ||
} | ||
} | ||
if (sourceText === undefined) { | ||
throw new Error(`Invalid source file: ${fileName}`); | ||
} | ||
return ts.createSourceFile(fileName, sourceText, ts.ScriptTarget.ES5, true); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters