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

Function doChange

test/fixtures/snapshot/typescript.js:150966–150997  ·  view source on GitHub ↗
(changes, sourceFile, decl)

Source from the content-addressed store, hash-verified

150964 : !decl.type && !!ts.getJSDocType(decl);
150965 }
150966 function doChange(changes, sourceFile, decl) {
150967 if (ts.isFunctionLikeDeclaration(decl) && (ts.getJSDocReturnType(decl) || decl.parameters.some(function (p) { return !!ts.getJSDocType(p); }))) {
150968 if (!decl.typeParameters) {
150969 var typeParameters = ts.getJSDocTypeParameterDeclarations(decl);
150970 if (typeParameters.length)
150971 changes.insertTypeParameters(sourceFile, decl, typeParameters);
150972 }
150973 var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* SyntaxKind.OpenParenToken */, sourceFile);
150974 if (needParens)
150975 changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */));
150976 for (var _i = 0, _a = decl.parameters; _i < _a.length; _i++) {
150977 var param = _a[_i];
150978 if (!param.type) {
150979 var paramType = ts.getJSDocType(param);
150980 if (paramType)
150981 changes.tryInsertTypeAnnotation(sourceFile, param, transformJSDocType(paramType));
150982 }
150983 }
150984 if (needParens)
150985 changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */));
150986 if (!decl.type) {
150987 var returnType = ts.getJSDocReturnType(decl);
150988 if (returnType)
150989 changes.tryInsertTypeAnnotation(sourceFile, decl, transformJSDocType(returnType));
150990 }
150991 }
150992 else {
150993 var jsdocType = ts.Debug.checkDefined(ts.getJSDocType(decl), "A JSDocType for this declaration should exist"); // If not defined, shouldn't have been an error to fix
150994 ts.Debug.assert(!decl.type, "The JSDocType decl should have a type"); // If defined, shouldn't have been an error to fix.
150995 changes.tryInsertTypeAnnotation(sourceFile, decl, transformJSDocType(jsdocType));
150996 }
150997 }
150998 function isDeclarationWithType(node) {
150999 return ts.isFunctionLikeDeclaration(node) ||
151000 node.kind === 254 /* SyntaxKind.VariableDeclaration */ ||

Calls 15

transformJSDocTypeFunction · 0.85
isValidCharacterFunction · 0.85
lastWhereFunction · 0.85
mapSuggestionDiagnosticFunction · 0.85
annotateSetAccessorFunction · 0.85
annotateParametersFunction · 0.85
annotateFunction · 0.85
annotateThisFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…