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

Function checkSignatureDeclarationDiagnostics

test/fixtures/snapshot/typescript.js:80210–80251  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

80208 }
80209 addLazyDiagnostic(checkSignatureDeclarationDiagnostics);
80210 function checkSignatureDeclarationDiagnostics() {
80211 checkCollisionWithArgumentsInGeneratedCode(node);
80212 var returnTypeNode = ts.getEffectiveReturnTypeNode(node);
80213 if (noImplicitAny && !returnTypeNode) {
80214 switch (node.kind) {
80215 case 175 /* SyntaxKind.ConstructSignature */:
80216 error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
80217 break;
80218 case 174 /* SyntaxKind.CallSignature */:
80219 error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
80220 break;
80221 }
80222 }
80223 if (returnTypeNode) {
80224 var functionFlags_1 = ts.getFunctionFlags(node);
80225 if ((functionFlags_1 & (4 /* FunctionFlags.Invalid */ | 1 /* FunctionFlags.Generator */)) === 1 /* FunctionFlags.Generator */) {
80226 var returnType = getTypeFromTypeNode(returnTypeNode);
80227 if (returnType === voidType) {
80228 error(returnTypeNode, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation);
80229 }
80230 else {
80231 // Naively, one could check that Generator<any, any, any> is assignable to the return type annotation.
80232 // However, that would not catch the error in the following case.
80233 //
80234 // interface BadGenerator extends Iterable<number>, Iterator<string> { }
80235 // function* g(): BadGenerator { } // Iterable and Iterator have different types!
80236 //
80237 var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || anyType;
80238 var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || generatorYieldType;
80239 var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || unknownType;
80240 var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* FunctionFlags.Async */));
80241 checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeNode);
80242 }
80243 }
80244 else if ((functionFlags_1 & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) {
80245 checkAsyncFunctionReturnType(node, returnTypeNode);
80246 }
80247 }
80248 if (node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 317 /* SyntaxKind.JSDocFunctionType */) {
80249 registerForUnusedIdentifiersCheck(node);
80250 }
80251 }
80252 }
80253 function checkClassForDuplicateDeclarations(node) {
80254 var instanceNames = new ts.Map();

Callers

nothing calls this directly

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…