MCPcopy Index your code
hub / github.com/nodejs/node / tryFile

Function tryFile

test/fixtures/snapshot/typescript.js:43620–43628  ·  view source on GitHub ↗

Return the file if it exists.

(fileName, onlyRecordFailures, state)

Source from the content-addressed store, hash-verified

43618 }
43619 /** Return the file if it exists. */
43620 function tryFile(fileName, onlyRecordFailures, state) {
43621 var _a, _b;
43622 if (!((_a = state.compilerOptions.moduleSuffixes) === null || _a === void 0 ? void 0 : _a.length)) {
43623 return tryFileLookup(fileName, onlyRecordFailures, state);
43624 }
43625 var ext = (_b = ts.tryGetExtensionFromPath(fileName)) !== null && _b !== void 0 ? _b : "";
43626 var fileNameNoExtension = ext ? ts.removeExtension(fileName, ext) : fileName;
43627 return ts.forEach(state.compilerOptions.moduleSuffixes, function (suffix) { return tryFileLookup(fileNameNoExtension + suffix + ext, onlyRecordFailures, state); });
43628 }
43629 function tryFileLookup(fileName, onlyRecordFailures, state) {
43630 if (!onlyRecordFailures) {
43631 if (state.host.fileExists(fileName)) {

Callers 4

loadJSOrExactTSFileNameFunction · 0.70
tryExtensionFunction · 0.70
loaderFunction · 0.70
tryLoadModuleUsingPathsFunction · 0.70

Calls 2

tryFileLookupFunction · 0.85
forEachMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…