(changes, importAdder, sourceFile, declaration, type, program, host)
| 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)) { |
no test coverage detected
searching dependent graphs…