( relativePath: string, language: Language, context: ResolutionContext, exists: (file: string) => boolean = (file) => context.fileExists(file) )
| 1414 | ]; |
| 1415 | |
| 1416 | function findSourceForEmittedSpecifier( |
| 1417 | relativePath: string, |
| 1418 | language: Language, |
| 1419 | context: ResolutionContext, |
| 1420 | exists: (file: string) => boolean = (file) => context.fileExists(file) |
| 1421 | ): string | null { |
| 1422 | if (!EMITTED_SPECIFIER_LANGUAGES.has(language)) return null; |
| 1423 | for (const [emitted, sources] of EMITTED_TO_SOURCE_EXTENSIONS) { |
| 1424 | if (!emitted.test(relativePath)) continue; |
| 1425 | const stem = relativePath.replace(emitted, ''); |
| 1426 | for (const ext of sources) { |
| 1427 | const candidate = stem + ext; |
| 1428 | if (exists(candidate)) return candidate; |
| 1429 | } |
| 1430 | return null; |
| 1431 | } |
| 1432 | return null; |
| 1433 | } |
| 1434 | |
| 1435 | /** Languages whose import specifiers can name the emitted `.js` of a `.ts` source. */ |
| 1436 | const EMITTED_SPECIFIER_LANGUAGES: ReadonlySet<string> = new Set([ |
no test coverage detected