MCPcopy Create free account
hub / github.com/nodejs/node / fileIncludeReasonToDiagnostics

Function fileIncludeReasonToDiagnostics

test/fixtures/snapshot/typescript.js:122925–123016  ·  view source on GitHub ↗
(program, reason, fileNameConvertor)

Source from the content-addressed store, hash-verified

122923 }
122924 ts.getMatchedIncludeSpec = getMatchedIncludeSpec;
122925 function fileIncludeReasonToDiagnostics(program, reason, fileNameConvertor) {
122926 var _a, _b;
122927 var options = program.getCompilerOptions();
122928 if (ts.isReferencedFile(reason)) {
122929 var referenceLocation = ts.getReferencedFileLocation(function (path) { return program.getSourceFileByPath(path); }, reason);
122930 var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"".concat(referenceLocation.text, "\"");
122931 var message = void 0;
122932 ts.Debug.assert(ts.isReferenceFileLocation(referenceLocation) || reason.kind === ts.FileIncludeKind.Import, "Only synthetic references are imports");
122933 switch (reason.kind) {
122934 case ts.FileIncludeKind.Import:
122935 if (ts.isReferenceFileLocation(referenceLocation)) {
122936 message = referenceLocation.packageId ?
122937 ts.Diagnostics.Imported_via_0_from_file_1_with_packageId_2 :
122938 ts.Diagnostics.Imported_via_0_from_file_1;
122939 }
122940 else if (referenceLocation.text === ts.externalHelpersModuleNameText) {
122941 message = referenceLocation.packageId ?
122942 ts.Diagnostics.Imported_via_0_from_file_1_with_packageId_2_to_import_importHelpers_as_specified_in_compilerOptions :
122943 ts.Diagnostics.Imported_via_0_from_file_1_to_import_importHelpers_as_specified_in_compilerOptions;
122944 }
122945 else {
122946 message = referenceLocation.packageId ?
122947 ts.Diagnostics.Imported_via_0_from_file_1_with_packageId_2_to_import_jsx_and_jsxs_factory_functions :
122948 ts.Diagnostics.Imported_via_0_from_file_1_to_import_jsx_and_jsxs_factory_functions;
122949 }
122950 break;
122951 case ts.FileIncludeKind.ReferenceFile:
122952 ts.Debug.assert(!referenceLocation.packageId);
122953 message = ts.Diagnostics.Referenced_via_0_from_file_1;
122954 break;
122955 case ts.FileIncludeKind.TypeReferenceDirective:
122956 message = referenceLocation.packageId ?
122957 ts.Diagnostics.Type_library_referenced_via_0_from_file_1_with_packageId_2 :
122958 ts.Diagnostics.Type_library_referenced_via_0_from_file_1;
122959 break;
122960 case ts.FileIncludeKind.LibReferenceDirective:
122961 ts.Debug.assert(!referenceLocation.packageId);
122962 message = ts.Diagnostics.Library_referenced_via_0_from_file_1;
122963 break;
122964 default:
122965 ts.Debug.assertNever(reason);
122966 }
122967 return ts.chainDiagnosticMessages(
122968 /*details*/ undefined, message, referenceText, toFileName(referenceLocation.file, fileNameConvertor), referenceLocation.packageId && ts.packageIdToString(referenceLocation.packageId));
122969 }
122970 switch (reason.kind) {
122971 case ts.FileIncludeKind.RootFile:
122972 if (!((_a = options.configFile) === null || _a === void 0 ? void 0 : _a.configFileSpecs))
122973 return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Root_file_specified_for_compilation);
122974 var fileName = ts.getNormalizedAbsolutePath(program.getRootFileNames()[reason.index], program.getCurrentDirectory());
122975 var matchedByFiles = getMatchedFileSpec(program, fileName);
122976 if (matchedByFiles)
122977 return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Part_of_files_list_in_tsconfig_json);
122978 var matchedByInclude = getMatchedIncludeSpec(program, fileName);
122979 return matchedByInclude ?
122980 ts.chainDiagnosticMessages(
122981 /*details*/ undefined, ts.Diagnostics.Matched_by_include_pattern_0_in_1, matchedByInclude, toFileName(options.configFile, fileNameConvertor)) :
122982 // Could be additional files specified as roots

Callers 1

explainFilesFunction · 0.85

Calls 5

toFileNameFunction · 0.85
getMatchedFileSpecFunction · 0.85
getMatchedIncludeSpecFunction · 0.85
concatMethod · 0.80
assertMethod · 0.80

Tested by

no test coverage detected