MCPcopy Create free account
hub / github.com/microsoft/typescript-go / tryFile

Method tryFile

internal/module/resolver.go:1582–1596  ·  view source on GitHub ↗
(fileName string)

Source from the content-addressed store, hash-verified

1580}
1581
1582func (r *resolutionState) tryFile(fileName string) (string, bool) {
1583 if len(r.compilerOptions.ModuleSuffixes) == 0 {
1584 return fileName, r.tryFileLookup(fileName)
1585 }
1586
1587 ext := tspath.TryGetExtensionFromPath(fileName)
1588 fileNameNoExtension := tspath.RemoveExtension(fileName, ext)
1589 for _, suffix := range r.compilerOptions.ModuleSuffixes {
1590 path := fileNameNoExtension + suffix + ext
1591 if r.tryFileLookup(path) {
1592 return path, true
1593 }
1594 }
1595 return fileName, false
1596}
1597
1598func (r *resolutionState) tryFileLookup(fileName string) bool {
1599 if r.resolver.host.FS().FileExists(fileName) {

Callers 3

tryExtensionMethod · 0.95

Calls 4

tryFileLookupMethod · 0.95
TryGetExtensionFromPathFunction · 0.92
RemoveExtensionFunction · 0.92
lenFunction · 0.85

Tested by

no test coverage detected