Skip to content

Instantly share code, notes, and snippets.

@fforw
Created April 13, 2021 12:42
Show Gist options
  • Select an option

  • Save fforw/4ae6c920a8ef3b890b1b53913c884bb9 to your computer and use it in GitHub Desktop.

Select an option

Save fforw/4ae6c920a8ef3b890b1b53913c884bb9 to your computer and use it in GitHub Desktop.
Recast/Jscodeshift builders (some ts missing)
j.noop();
j.doExpression(body)
j.bindExpression(object, callee)
j.parenthesizedExpression(expression)
j.exportNamespaceSpecifier(exported)
j.exportDefaultSpecifier(exported)
j.commentBlock(value, /*optional:*/ leading, trailing);
j.commentLine(value, /*optional:*/ leading, trailing);
j.directive(value)
j.directiveLiteral(value)
j.interpreterDirective(value)
j.blockStatement(body)
j.program(body)
j.stringLiteral(value)
j.numericLiteral(value)
j.bigIntLiteral(value)
j.nullLiteral()
j.booleanLiteral(value)
j.regExpLiteral(pattern, flags)
j.objectExpression(properties)
j.objectMethod(kind, key, params, body, computed)
j.objectProperty(key, value)
j.classBody(body)
j.classMethod(kind, key, params, body, computed, static)
j.classPrivateMethod(key, params, body, kind, computed, static)
j.objectPattern(properties)
j.spreadProperty(argument)
j.restProperty(argument)
j.forAwaitStatement(left, right, body)
j.import();
j.file(program, name)
j.program(body)
j.emptyStatement();
j.blockStatement(body)
j.expressionStatement(expression)
j.ifStatement(test, consequent, alternate)
j.labeledStatement(label, body)
j.breakStatement(label)
j.continueStatement(label)
j.withStatement(object, body)
j.switchStatement(discriminant, cases, lexical)
j.returnStatement(argument)
j.throwStatement(argument)
j.tryStatement(block, handler, finalizer)
j.catchClause(param, guard, body)
j.whileStatement(test, body)
j.doWhileStatement(body, test)
j.forStatement(init, test, update, body)
j.forInStatement(left, right, body)
j.debuggerStatement();
j.functionDeclaration(id, params, body)
j.functionExpression(id, params, body);
j.variableDeclaration(kind, declarations)
j.variableDeclarator(id, init)
j.thisExpression();
j.arrayExpression(elements)
j.objectExpression(properties)
j.property(kind, key, value)
j.sequenceExpression(expressions)
j.unaryExpression(operator, argument, prefix)
j.binaryExpression(operator, left, right)
j.assignmentExpression(operator, left, right)
j.updateExpression(operator, argument, prefix)
j.logicalExpression(operator, left, right)
j.conditionalExpression(test, consequent, alternate)
j.newExpression(callee, arguments)
j.callExpression(callee, arguments)
j.memberExpression(object, property, computed)
j.switchCase(test, consequent)
j.identifier(name)
j.literal(value)
j.awaitExpression(argument)
j.spreadProperty(argument)
j.spreadPropertyPattern(argument)
j.importExpression(source)
j.exportAllDeclaration(source, exported)
j.chainExpression(expression)
j.optionalCallExpression(callee, arguments, optional)
j.optionalMemberExpression(object, property, computed, optional)
j.restElement(argument)
j.spreadElementPattern(argument)
j.functionDeclaration(id, params, body, generator, expression)
j.functionExpression(id, params, body, generator, expression);
j.arrowFunctionExpression(params, body, expression)
j.forOfStatement(left, right, body)
j.yieldExpression(argument, delegate)
j.generatorExpression(body, blocks, filter)
j.comprehensionExpression(body, blocks, filter)
j.comprehensionBlock(left, right, each)
j.propertyPattern(key, pattern)
j.objectPattern(properties)
j.arrayPattern(elements)
j.spreadElement(argument)
j.assignmentPattern(left, right)
j.methodDefinition(kind, key, value, static)
j.classProperty(key)
j.classPropertyDefinition(definition)
j.classBody(body)
j.classDeclaration(id, body, superClass)
j.classExpression(id, body, superClass)
j.super();
j.importSpecifier(imported, local)
j.importDefaultSpecifier(local);
j.importNamespaceSpecifier(local);
j.importDeclaration(specifiers, source, importKind)
j.exportNamedDeclaration(declaration, specifiers, source)
j.exportSpecifier(local, exported)
j.exportDefaultDeclaration(declaration)
j.exportAllDeclaration(source)
j.taggedTemplateExpression(tag, quasi)
j.templateLiteral(quasis, expressions)
j.templateElement(value, tail)
j.metaProperty(meta, property)
j.exportSpecifier(id, name);
j.exportBatchSpecifier();
j.exportDeclaration(default, declaration, specifiers, source)
j.block(value, /*optional:*/ leading, trailing);
j.line(value, /*optional:*/ leading, trailing);
j.awaitExpression(argument, all)
j.decorator(expression)
j.privateName(id)
j.classPrivateProperty(key, value)
j.anyTypeAnnotation();
j.emptyTypeAnnotation();
j.mixedTypeAnnotation();
j.voidTypeAnnotation();
j.symbolTypeAnnotation();
j.numberTypeAnnotation();
j.bigIntTypeAnnotation();
j.numberLiteralTypeAnnotation(value, raw)
j.numericLiteralTypeAnnotation(value, raw)
j.bigIntLiteralTypeAnnotation(value, raw)
j.stringTypeAnnotation();
j.stringLiteralTypeAnnotation(value, raw)
j.booleanTypeAnnotation();
j.booleanLiteralTypeAnnotation(value, raw)
j.typeAnnotation(typeAnnotation)
j.nullableTypeAnnotation(typeAnnotation)
j.nullLiteralTypeAnnotation();
j.nullTypeAnnotation();
j.thisTypeAnnotation();
j.existsTypeAnnotation();
j.existentialTypeParam();
j.functionTypeAnnotation(params, returnType, rest, typeParameters)
j.functionTypeParam(name, typeAnnotation, optional)
j.arrayTypeAnnotation(elementType)
j.objectTypeAnnotation(properties, indexers, callProperties)
j.variance(kind)
j.objectTypeProperty(key, value, optional)
j.objectTypeIndexer(id, key, value)
j.objectTypeCallProperty(value)
j.qualifiedTypeIdentifier(qualification, id)
j.genericTypeAnnotation(id, typeParameters)
j.memberTypeAnnotation(object, property)
j.unionTypeAnnotation(types)
j.intersectionTypeAnnotation(types)
j.typeofTypeAnnotation(argument)
j.objectTypeSpreadProperty(argument)
j.objectTypeInternalSlot(id, value, optional, static, method)
j.typeParameterDeclaration(params)
j.typeParameterInstantiation(params)
j.typeParameter(name, variance, bound, default)
j.classImplements(id)
j.interfaceTypeAnnotation(body, extends)
j.interfaceDeclaration(id, body, extends)
j.declareInterface(id, body, extends);
j.interfaceExtends(id)
j.typeAlias(id, typeParameters, right)
j.declareTypeAlias(id, typeParameters, right);
j.opaqueType(id, typeParameters, impltype, supertype)
j.declareOpaqueType(id, typeParameters, supertype)
j.typeCastExpression(expression, typeAnnotation)
j.tupleTypeAnnotation(types)
j.declareVariable(id)
j.declareFunction(id)
j.declareClass(id);
j.declareModule(id, body)
j.declareModuleExports(typeAnnotation)
j.declareExportDeclaration(default, declaration, specifiers, source)
j.declareExportAllDeclaration(source)
j.inferredPredicate();
j.declaredPredicate(value)
j.enumDeclaration(id, body)
j.enumBooleanBody(members, explicitType)
j.enumNumberBody(members, explicitType)
j.enumStringBody(members, explicitType)
j.enumSymbolBody(members)
j.enumBooleanMember(id, init)
j.enumNumberMember(id, init)
j.enumStringMember(id, init)
j.enumDefaultedMember(id)
j.jSXAttribute(name, value)
j.jSXIdentifier(name)
j.jSXNamespacedName(namespace, name)
j.jSXMemberExpression(object, property)
j.jSXSpreadAttribute(argument)
j.jSXExpressionContainer(expression)
j.jSXElement(openingElement, closingElement, children)
j.jSXOpeningElement(name, attributes, selfClosing)
j.jSXClosingElement(name)
j.jSXFragment(openingFragment, closingFragment, children)
j.jSXOpeningFragment();
j.jSXClosingFragment();
j.jSXText(value, raw)
j.jSXEmptyExpression();
j.jSXSpreadChild(expression)
j.classProperty(key, value, typeAnnotation, static)
j.tsTypeReference(typeName, typeParameters)
j.tsQualifiedName(left, right)
j.tsAsExpression(expression, typeAnnotation)
j.tsNonNullExpression(expression)
j.tsArrayType(elementType)
j.tsLiteralType(literal)
j.tsConditionalType(checkType, extendsType, trueType, falseType)
j.tsInferType(typeParameter)
j.tsParenthesizedType(typeAnnotation)
j.tsDeclareFunction(id, params, returnType)
j.tsDeclareMethod(key, params, returnType)
j.tsMappedType(typeParameter, typeAnnotation)
j.tsTupleType(elementTypes)
j.tsNamedTupleMember(label, elementType, optional)
j.tsRestType(typeAnnotation)
j.tsOptionalType(typeAnnotation)
j.tsIndexedAccessType(objectType, indexType)
j.tsTypeOperator(operator)
j.tsTypeAnnotation(typeAnnotation)
j.tsIndexSignature(parameters, typeAnnotation)
j.tsPropertySignature(key, typeAnnotation, optional)
j.tsTypePredicate(parameterName, typeAnnotation, asserts)
j.tsEnumMember(id, initializer)
j.tsTypeQuery(exprName)
j.tsTypeLiteral(members)
j.tsTypeParameter(name, constraint, default)
j.tsTypeAssertion(typeAnnotation, expression)
j.tsTypeParameterDeclaration(params)
j.tsTypeParameterInstantiation(params)
j.tsEnumDeclaration(id, members)
j.tsTypeAliasDeclaration(id, typeAnnotation)
j.tsModuleBlock(body)
j.tsModuleDeclaration(id, body)
j.tsImportType(argument, qualifier, typeParameters)
j.tsImportEqualsDeclaration(id, moduleReference)
j.tsExternalModuleReference(expression)
j.tsExportAssignment(expression)
j.tsNamespaceExportDeclaration(id)
j.tsInterfaceBody(body)
j.tsExpressionWithTypeArguments(expression, typeParameters)
j.tsInterfaceDeclaration(id, body)
j.tsParameterProperty(parameter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment