(extensionless string, extensions extensions, originalExtension string)
| 1451 | } |
| 1452 | |
| 1453 | func (r *resolutionState) tryAddingExtensions(extensionless string, extensions extensions, originalExtension string) *resolved { |
| 1454 | directory := tspath.GetDirectoryPath(extensionless) |
| 1455 | if directory != "" && !r.resolver.host.FS().DirectoryExists(directory) { |
| 1456 | return continueSearching() |
| 1457 | } |
| 1458 | |
| 1459 | switch originalExtension { |
| 1460 | case tspath.ExtensionMjs, tspath.ExtensionMts, tspath.ExtensionDmts: |
| 1461 | if extensions&extensionsTypeScript != 0 { |
| 1462 | if resolved := r.tryExtension(tspath.ExtensionMts, extensionless, originalExtension == tspath.ExtensionMts || originalExtension == tspath.ExtensionDmts); !resolved.shouldContinueSearching() { |
| 1463 | return resolved |
| 1464 | } |
| 1465 | } |
| 1466 | if extensions&extensionsDeclaration != 0 { |
| 1467 | if resolved := r.tryExtension(tspath.ExtensionDmts, extensionless, originalExtension == tspath.ExtensionMts || originalExtension == tspath.ExtensionDmts); !resolved.shouldContinueSearching() { |
| 1468 | return resolved |
| 1469 | } |
| 1470 | } |
| 1471 | if extensions&extensionsJavaScript != 0 { |
| 1472 | if resolved := r.tryExtension(tspath.ExtensionMjs, extensionless, false); !resolved.shouldContinueSearching() { |
| 1473 | return resolved |
| 1474 | } |
| 1475 | } |
| 1476 | return continueSearching() |
| 1477 | case tspath.ExtensionCjs, tspath.ExtensionCts, tspath.ExtensionDcts: |
| 1478 | if extensions&extensionsTypeScript != 0 { |
| 1479 | if resolved := r.tryExtension(tspath.ExtensionCts, extensionless, originalExtension == tspath.ExtensionCts || originalExtension == tspath.ExtensionDcts); !resolved.shouldContinueSearching() { |
| 1480 | return resolved |
| 1481 | } |
| 1482 | } |
| 1483 | if extensions&extensionsDeclaration != 0 { |
| 1484 | if resolved := r.tryExtension(tspath.ExtensionDcts, extensionless, originalExtension == tspath.ExtensionCts || originalExtension == tspath.ExtensionDcts); !resolved.shouldContinueSearching() { |
| 1485 | return resolved |
| 1486 | } |
| 1487 | } |
| 1488 | if extensions&extensionsJavaScript != 0 { |
| 1489 | if resolved := r.tryExtension(tspath.ExtensionCjs, extensionless, false); !resolved.shouldContinueSearching() { |
| 1490 | return resolved |
| 1491 | } |
| 1492 | } |
| 1493 | return continueSearching() |
| 1494 | case tspath.ExtensionJson: |
| 1495 | if extensions&extensionsDeclaration != 0 { |
| 1496 | if resolved := r.tryExtension(".d.json.ts", extensionless, false); !resolved.shouldContinueSearching() { |
| 1497 | return resolved |
| 1498 | } |
| 1499 | } |
| 1500 | if extensions&extensionsJson != 0 { |
| 1501 | if resolved := r.tryExtension(tspath.ExtensionJson, extensionless, false); !resolved.shouldContinueSearching() { |
| 1502 | return resolved |
| 1503 | } |
| 1504 | } |
| 1505 | return continueSearching() |
| 1506 | case tspath.ExtensionTsx, tspath.ExtensionJsx: |
| 1507 | // basically idendical to the ts/js case below, but prefers matching tsx and jsx files exactly before falling back to the ts or js file path |
| 1508 | // (historically, we disallow having both a a.ts and a.tsx file in the same compilation, since their outputs clash) |
| 1509 | // TODO: We should probably error if `"./a.tsx"` resolved to `"./a.ts"`, right? |
| 1510 | if extensions&extensionsTypeScript != 0 { |
no test coverage detected