(declaration: ExportDeclaration | ImportDeclaration)
| 818 | * @see https://github.com/dsherret/ts-morph/blob/42d811ed9a5177fc678a5bfec4923a2048124fe0/packages/ts-morph/src/compiler/ast/module/ExportDeclaration.ts#L160 |
| 819 | */ |
| 820 | export const getModuleSpecifierSourceFile = (declaration: ExportDeclaration | ImportDeclaration) => { |
| 821 | const project = declaration.getProject() |
| 822 | const moduleName = declaration.getModuleSpecifierValue() |
| 823 | |
| 824 | if (!moduleName) return |
| 825 | |
| 826 | const containingFile = declaration.getSourceFile().getFilePath() |
| 827 | const resolved = ts.resolveModuleName( |
| 828 | moduleName, |
| 829 | containingFile, |
| 830 | project.getCompilerOptions(), |
| 831 | project.getModuleResolutionHost(), |
| 832 | ) |
| 833 | if (!resolved.resolvedModule) return |
| 834 | |
| 835 | const sourceFile = project.addSourceFileAtPath(resolved.resolvedModule.resolvedFileName) |
| 836 | |
| 837 | return sourceFile |
| 838 | } |
| 839 | |
| 840 | function resolveVarDeclarationFromExportWithName( |
| 841 | symbolName: string, |
no test coverage detected