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

Function getTypeFromBindingElement

test/fixtures/snapshot/typescript.js:56393–56412  ·  view source on GitHub ↗
(element, includePatternInType, reportErrors)

Source from the content-addressed store, hash-verified

56391 // one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding
56392 // pattern. Otherwise, it is the type any.
56393 function getTypeFromBindingElement(element, includePatternInType, reportErrors) {
56394 if (element.initializer) {
56395 // The type implied by a binding pattern is independent of context, so we check the initializer with no
56396 // contextual type or, if the element itself is a binding pattern, with the type implied by that binding
56397 // pattern.
56398 var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType;
56399 return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* CheckMode.Normal */, contextualType)));
56400 }
56401 if (ts.isBindingPattern(element.name)) {
56402 return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
56403 }
56404 if (reportErrors && !declarationBelongsToPrivateAmbientMember(element)) {
56405 reportImplicitAny(element, anyType);
56406 }
56407 // When we're including the pattern in the type (an indication we're obtaining a contextual type), we
56408 // use the non-inferrable any type. Inference will never directly infer this type, but it is possible
56409 // to infer a type that contains it, e.g. for a binding pattern like [foo] or { foo }. In such cases,
56410 // widening of the binding pattern type substitutes a regular any for the non-inferrable any.
56411 return includePatternInType ? nonInferrableAnyType : anyType;
56412 }
56413 // Return the type implied by an object binding pattern
56414 function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) {
56415 var members = ts.createSymbolTable();

Callers 3

padTupleTypeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…