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

Function getTypeOfAccessors

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

Source from the content-addressed store, hash-verified

56690 return getThisTypeOfSignature(getSignatureFromDeclaration(declaration));
56691 }
56692 function getTypeOfAccessors(symbol) {
56693 var links = getSymbolLinks(symbol);
56694 if (!links.type) {
56695 if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) {
56696 return errorType;
56697 }
56698 var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */);
56699 var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */);
56700 // We try to resolve a getter type annotation, a setter type annotation, or a getter function
56701 // body return type inference, in that order.
56702 var type = getter && ts.isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) ||
56703 getAnnotatedAccessorType(getter) ||
56704 getAnnotatedAccessorType(setter) ||
56705 getter && getter.body && getReturnTypeFromBody(getter);
56706 if (!type) {
56707 if (setter && !isPrivateWithinAmbient(setter)) {
56708 errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
56709 }
56710 else if (getter && !isPrivateWithinAmbient(getter)) {
56711 errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
56712 }
56713 type = anyType;
56714 }
56715 if (!popTypeResolution()) {
56716 if (getAnnotatedAccessorTypeNode(getter)) {
56717 error(getter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
56718 }
56719 else if (getAnnotatedAccessorTypeNode(setter)) {
56720 error(setter, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
56721 }
56722 else if (getter && noImplicitAny) {
56723 error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol));
56724 }
56725 type = anyType;
56726 }
56727 links.type = type;
56728 }
56729 return links.type;
56730 }
56731 function getWriteTypeOfAccessors(symbol) {
56732 var links = getSymbolLinks(symbol);
56733 if (!links.writeType) {

Calls 11

getSymbolLinksFunction · 0.85
pushTypeResolutionFunction · 0.85
getAnnotatedAccessorTypeFunction · 0.85
getReturnTypeFromBodyFunction · 0.85
isPrivateWithinAmbientFunction · 0.85
errorOrSuggestionFunction · 0.85
symbolToStringFunction · 0.85
popTypeResolutionFunction · 0.85
errorFunction · 0.70

Tested by

no test coverage detected