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

Function processPragmasIntoFields

test/fixtures/snapshot/typescript.js:38902–38980  ·  view source on GitHub ↗
(context, reportDiagnostic)

Source from the content-addressed store, hash-verified

38900 ts.processCommentPragmas = processCommentPragmas;
38901 /*@internal*/
38902 function processPragmasIntoFields(context, reportDiagnostic) {
38903 context.checkJsDirective = undefined;
38904 context.referencedFiles = [];
38905 context.typeReferenceDirectives = [];
38906 context.libReferenceDirectives = [];
38907 context.amdDependencies = [];
38908 context.hasNoDefaultLib = false;
38909 context.pragmas.forEach(function (entryOrList, key) {
38910 // TODO: The below should be strongly type-guarded and not need casts/explicit annotations, since entryOrList is related to
38911 // key and key is constrained to a union; but it's not (see GH#21483 for at least partial fix) :(
38912 switch (key) {
38913 case "reference": {
38914 var referencedFiles_1 = context.referencedFiles;
38915 var typeReferenceDirectives_1 = context.typeReferenceDirectives;
38916 var libReferenceDirectives_1 = context.libReferenceDirectives;
38917 ts.forEach(ts.toArray(entryOrList), function (arg) {
38918 var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path, res = _a["resolution-mode"];
38919 if (arg.arguments["no-default-lib"]) {
38920 context.hasNoDefaultLib = true;
38921 }
38922 else if (types) {
38923 var parsed = parseResolutionMode(res, types.pos, types.end, reportDiagnostic);
38924 typeReferenceDirectives_1.push(__assign({ pos: types.pos, end: types.end, fileName: types.value }, (parsed ? { resolutionMode: parsed } : {})));
38925 }
38926 else if (lib) {
38927 libReferenceDirectives_1.push({ pos: lib.pos, end: lib.end, fileName: lib.value });
38928 }
38929 else if (path) {
38930 referencedFiles_1.push({ pos: path.pos, end: path.end, fileName: path.value });
38931 }
38932 else {
38933 reportDiagnostic(arg.range.pos, arg.range.end - arg.range.pos, ts.Diagnostics.Invalid_reference_directive_syntax);
38934 }
38935 });
38936 break;
38937 }
38938 case "amd-dependency": {
38939 context.amdDependencies = ts.map(ts.toArray(entryOrList), function (x) { return ({ name: x.arguments.name, path: x.arguments.path }); });
38940 break;
38941 }
38942 case "amd-module": {
38943 if (entryOrList instanceof Array) {
38944 for (var _i = 0, entryOrList_1 = entryOrList; _i < entryOrList_1.length; _i++) {
38945 var entry = entryOrList_1[_i];
38946 if (context.moduleName) {
38947 // TODO: It's probably fine to issue this diagnostic on all instances of the pragma
38948 reportDiagnostic(entry.range.pos, entry.range.end - entry.range.pos, ts.Diagnostics.An_AMD_module_cannot_have_multiple_name_assignments);
38949 }
38950 context.moduleName = entry.arguments.name;
38951 }
38952 }
38953 else {
38954 context.moduleName = entryOrList.arguments.name;
38955 }
38956 break;
38957 }
38958 case "ts-nocheck":
38959 case "ts-check": {

Callers 1

parseSourceFileWorkerFunction · 0.85

Calls 6

parseResolutionModeFunction · 0.85
forEachMethod · 0.65
toArrayMethod · 0.65
mapMethod · 0.65
pushMethod · 0.45
failMethod · 0.45

Tested by

no test coverage detected