Gets the TypeScript source file of the specified path.
(filePath: string)
| 78 | |
| 79 | /** Gets the TypeScript source file of the specified path. */ |
| 80 | getSourceFile(filePath: string): ts.SourceFile { |
| 81 | const resolvedPath = resolve(filePath); |
| 82 | if (this._sourceFileCache.has(resolvedPath)) { |
| 83 | return this._sourceFileCache.get(resolvedPath)!; |
| 84 | } |
| 85 | const fileContent = readFileSync(resolvedPath, 'utf8'); |
| 86 | const sourceFile = ts.createSourceFile( |
| 87 | resolvedPath, |
| 88 | fileContent, |
| 89 | ts.ScriptTarget.Latest, |
| 90 | false, |
| 91 | ); |
| 92 | this._sourceFileCache.set(resolvedPath, sourceFile); |
| 93 | return sourceFile; |
| 94 | } |
| 95 | |
| 96 | /** Resolves the given import specifier with respect to the specified containing file path. */ |
| 97 | private _resolveImport(specifier: string, containingFilePath: string): string | null { |