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

Function assignParameterType

test/fixtures/snapshot/typescript.js:77739–77755  ·  view source on GitHub ↗
(parameter, type)

Source from the content-addressed store, hash-verified

77737 }
77738 }
77739 function assignParameterType(parameter, type) {
77740 var links = getSymbolLinks(parameter);
77741 if (!links.type) {
77742 var declaration = parameter.valueDeclaration;
77743 links.type = type || (declaration ? getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true) : getTypeOfSymbol(parameter));
77744 if (declaration && declaration.name.kind !== 79 /* SyntaxKind.Identifier */) {
77745 // if inference didn't come up with anything but unknown, fall back to the binding pattern if present.
77746 if (links.type === unknownType) {
77747 links.type = getTypeFromBindingPattern(declaration.name);
77748 }
77749 assignBindingElementTypes(declaration.name, links.type);
77750 }
77751 }
77752 else if (type) {
77753 ts.Debug.assertEqual(links.type, type, "Parameter symbol already has a cached type which differs from newly assigned type");
77754 }
77755 }
77756 // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push
77757 // the destructured type into the contained binding elements.
77758 function assignBindingElementTypes(pattern, parentType) {

Calls 5

getSymbolLinksFunction · 0.85
getTypeOfSymbolFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…