( relativePath: string, language: Language, context: ResolutionContext, exists: (file: string) => boolean = (file) => context.fileExists(file) )
| 1475 | ]; |
| 1476 | |
| 1477 | function findSourceForEmittedSpecifier( |
| 1478 | relativePath: string, |
| 1479 | language: Language, |
| 1480 | context: ResolutionContext, |
| 1481 | exists: (file: string) => boolean = (file) => context.fileExists(file) |
| 1482 | ): string | null { |
| 1483 | if (!EMITTED_SPECIFIER_LANGUAGES.has(language)) return null; |
| 1484 | for (const [emitted, sources] of EMITTED_TO_SOURCE_EXTENSIONS) { |
| 1485 | if (!emitted.test(relativePath)) continue; |
| 1486 | const stem = relativePath.replace(emitted, ''); |
| 1487 | for (const ext of sources) { |
| 1488 | const candidate = stem + ext; |
| 1489 | if (exists(candidate)) return candidate; |
| 1490 | } |
| 1491 | return null; |
| 1492 | } |
| 1493 | return null; |
| 1494 | } |
| 1495 | |
| 1496 | /** Languages whose import specifiers can name the emitted `.js` of a `.ts` source. */ |
| 1497 | const EMITTED_SPECIFIER_LANGUAGES: ReadonlySet<string> = new Set([ |
no test coverage detected