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

Function reportImplementationExpectedError

test/fixtures/snapshot/typescript.js:80975–81035  ·  view source on GitHub ↗
(node)

Source from the content-addressed store, hash-verified

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;
80978 }
80979 var seen = false;
80980 var subsequentNode = ts.forEachChild(node.parent, function (c) {
80981 if (seen) {
80982 return c;
80983 }
80984 else {
80985 seen = c === node;
80986 }
80987 });
80988 // We may be here because of some extra nodes between overloads that could not be parsed into a valid node.
80989 // In this case the subsequent node is not really consecutive (.pos !== node.end), and we must ignore it here.
80990 if (subsequentNode && subsequentNode.pos === node.end) {
80991 if (subsequentNode.kind === node.kind) {
80992 var errorNode_1 = subsequentNode.name || subsequentNode;
80993 var subsequentName = subsequentNode.name;
80994 if (node.name && subsequentName && (
80995 // both are private identifiers
80996 ts.isPrivateIdentifier(node.name) && ts.isPrivateIdentifier(subsequentName) && node.name.escapedText === subsequentName.escapedText ||
80997 // Both are computed property names
80998 // TODO: GH#17345: These are methods, so handle computed name case. (`Always allowing computed property names is *not* the correct behavior!)
80999 ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) ||
81000 // Both are literal property names that are the same.
81001 ts.isPropertyNameLiteral(node.name) && ts.isPropertyNameLiteral(subsequentName) &&
81002 ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) {
81003 var reportError = (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */) &&
81004 ts.isStatic(node) !== ts.isStatic(subsequentNode);
81005 // we can get here in two cases
81006 // 1. mixed static and instance class members
81007 // 2. something with the same name was defined before the set of overloads that prevents them from merging
81008 // here we'll report error only for the first case since for second we should already report error in binder
81009 if (reportError) {
81010 var diagnostic = ts.isStatic(node) ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static;
81011 error(errorNode_1, diagnostic);
81012 }
81013 return;
81014 }
81015 if (ts.nodeIsPresent(subsequentNode.body)) {
81016 error(errorNode_1, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name));
81017 return;
81018 }
81019 }
81020 }
81021 var errorNode = node.name || node;
81022 if (isConstructor) {
81023 error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing);
81024 }
81025 else {
81026 // Report different errors regarding non-consecutive blocks of declarations depending on whether
81027 // the node in question is abstract.
81028 if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) {
81029 error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive);
81030 }
81031 else {
81032 error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration);

Calls 2

forEachChildMethod · 0.80
errorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…