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

Function checkFunctionOrConstructorSymbolWorker

test/fixtures/snapshot/typescript.js:80920–81139  ·  view source on GitHub ↗
(symbol)

Source from the content-addressed store, hash-verified

80918 addLazyDiagnostic(function () { return checkFunctionOrConstructorSymbolWorker(symbol); });
80919 }
80920 function checkFunctionOrConstructorSymbolWorker(symbol) {
80921 function getCanonicalOverload(overloads, implementation) {
80922 // Consider the canonical set of flags to be the flags of the bodyDeclaration or the first declaration
80923 // Error on all deviations from this canonical set of flags
80924 // The caveat is that if some overloads are defined in lib.d.ts, we don't want to
80925 // report the errors on those. To achieve this, we will say that the implementation is
80926 // the canonical signature only if it is in the same container as the first overload
80927 var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent;
80928 return implementationSharesContainerWithFirstOverload ? implementation : overloads[0];
80929 }
80930 function checkFlagAgreementBetweenOverloads(overloads, implementation, flagsToCheck, someOverloadFlags, allOverloadFlags) {
80931 // Error if some overloads have a flag that is not shared by all overloads. To find the
80932 // deviations, we XOR someOverloadFlags with allOverloadFlags
80933 var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags;
80934 if (someButNotAllOverloadFlags !== 0) {
80935 var canonicalFlags_1 = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck);
80936 ts.forEach(overloads, function (o) {
80937 var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags_1;
80938 if (deviation & 1 /* ModifierFlags.Export */) {
80939 error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported);
80940 }
80941 else if (deviation & 2 /* ModifierFlags.Ambient */) {
80942 error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient);
80943 }
80944 else if (deviation & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) {
80945 error(ts.getNameOfDeclaration(o) || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected);
80946 }
80947 else if (deviation & 128 /* ModifierFlags.Abstract */) {
80948 error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract);
80949 }
80950 });
80951 }
80952 }
80953 function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) {
80954 if (someHaveQuestionToken !== allHaveQuestionToken) {
80955 var canonicalHasQuestionToken_1 = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation));
80956 ts.forEach(overloads, function (o) {
80957 var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken_1;
80958 if (deviation) {
80959 error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required);
80960 }
80961 });
80962 }
80963 }
80964 var flagsToCheck = 1 /* ModifierFlags.Export */ | 2 /* ModifierFlags.Ambient */ | 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */ | 128 /* ModifierFlags.Abstract */;
80965 var someNodeFlags = 0 /* ModifierFlags.None */;
80966 var allNodeFlags = flagsToCheck;
80967 var someHaveQuestionToken = false;
80968 var allHaveQuestionToken = true;
80969 var hasOverloads = false;
80970 var bodyDeclaration;
80971 var lastSeenNonAmbientDeclaration;
80972 var previousDeclaration;
80973 var declarations = symbol.declarations;
80974 var isConstructor = (symbol.flags & 16384 /* SymbolFlags.Constructor */) !== 0;
80975 function reportImplementationExpectedError(node) {
80976 if (node.name && ts.nodeIsMissing(node.name)) {
80977 return;

Callers 1

Calls 13

getSignaturesOfSymbolFunction · 0.85
errorFunction · 0.70
forEachMethod · 0.65
mapMethod · 0.65
filterMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…