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

Function annotate

test/fixtures/snapshot/typescript.js:156776–156792  ·  view source on GitHub ↗
(changes, importAdder, sourceFile, declaration, type, program, host)

Source from the content-addressed store, hash-verified

156774 }
156775 }
156776 function annotate(changes, importAdder, sourceFile, declaration, type, program, host) {
156777 var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host);
156778 if (typeNode) {
156779 if (ts.isInJSFile(sourceFile) && declaration.kind !== 166 /* SyntaxKind.PropertySignature */) {
156780 var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration;
156781 if (!parent) {
156782 return;
156783 }
156784 var typeExpression = ts.factory.createJSDocTypeExpression(typeNode);
156785 var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.factory.createJSDocReturnTag(/*tagName*/ undefined, typeExpression, /*comment*/ undefined) : ts.factory.createJSDocTypeTag(/*tagName*/ undefined, typeExpression, /*comment*/ undefined);
156786 changes.addJSDocTags(sourceFile, parent, [typeTag]);
156787 }
156788 else if (!tryReplaceImportTypeNodeWithAutoImport(typeNode, declaration, sourceFile, changes, importAdder, ts.getEmitScriptTarget(program.getCompilerOptions()))) {
156789 changes.tryInsertTypeAnnotation(sourceFile, declaration, typeNode);
156790 }
156791 }
156792 }
156793 function tryReplaceImportTypeNodeWithAutoImport(typeNode, declaration, sourceFile, changes, importAdder, scriptTarget) {
156794 var importableReference = codefix.tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
156795 if (importableReference && changes.tryInsertTypeAnnotation(sourceFile, declaration, importableReference.typeNode)) {

Callers 14

doChangeFunction · 0.85
annotateParametersFunction · 0.85
annotateSetAccessorFunction · 0.85
duplicateElementMethod · 0.85
insertRandomValueMethod · 0.85
insertHoleMethod · 0.85
removeElementsMethod · 0.85
shuffleMethod · 0.85
swapPropertyValuesMethod · 0.85
insertRandomValueMethod · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…