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

Function widenTypeForVariableLikeDeclaration

test/fixtures/snapshot/typescript.js:56495–56519  ·  view source on GitHub ↗
(type, declaration, reportErrors)

Source from the content-addressed store, hash-verified

56493 return globalSymbol && symbol && symbol === globalSymbol;
56494 }
56495 function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors) {
56496 if (type) {
56497 // TODO: If back compat with pre-3.0/4.0 libs isn't required, remove the following SymbolConstructor special case transforming `symbol` into `unique symbol`
56498 if (type.flags & 4096 /* TypeFlags.ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) {
56499 type = getESSymbolLikeTypeForNode(declaration);
56500 }
56501 if (reportErrors) {
56502 reportErrorsFromWidening(declaration, type);
56503 }
56504 // always widen a 'unique symbol' type if the type was created for a different declaration.
56505 if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) {
56506 type = esSymbolType;
56507 }
56508 return getWidenedType(type);
56509 }
56510 // Rest parameters default to type any[], other parameters default to type any
56511 type = ts.isParameter(declaration) && declaration.dotDotDotToken ? anyArrayType : anyType;
56512 // Report implicit any errors unless this is a private property within an ambient declaration
56513 if (reportErrors) {
56514 if (!declarationBelongsToPrivateAmbientMember(declaration)) {
56515 reportImplicitAny(declaration, type);
56516 }
56517 }
56518 return type;
56519 }
56520 function declarationBelongsToPrivateAmbientMember(declaration) {
56521 var root = ts.getRootDeclaration(declaration);
56522 var memberDeclaration = root.kind === 164 /* SyntaxKind.Parameter */ ? root.parent : root;

Calls 7

reportErrorsFromWideningFunction · 0.85
getSymbolOfNodeFunction · 0.85
getWidenedTypeFunction · 0.85
reportImplicitAnyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…