function createTypeHandlerCall()

in src/transforms/deprecation-warnings.ts [618:682]


function createTypeHandlerCall(
  functionName: string,
  parameter: string,
  collectionKind?: spec.CollectionKind,
): ts.Statement {
  switch (collectionKind) {
    case spec.CollectionKind.Array:
      return ts.factory.createIfStatement(
        ts.factory.createBinaryExpression(
          ts.factory.createIdentifier(parameter),
          ts.SyntaxKind.ExclamationEqualsToken,
          ts.factory.createNull(),
        ),
        ts.factory.createForOfStatement(
          undefined,
          ts.factory.createVariableDeclarationList(
            [ts.factory.createVariableDeclaration(FOR_LOOP_ITEM_NAME)],
            ts.NodeFlags.Const,
          ),
          ts.factory.createIdentifier(parameter),
          createTypeHandlerCall(functionName, FOR_LOOP_ITEM_NAME),
        ),
      );
    case spec.CollectionKind.Map:
      return ts.factory.createIfStatement(
        ts.factory.createBinaryExpression(
          ts.factory.createIdentifier(parameter),
          ts.SyntaxKind.ExclamationEqualsToken,
          ts.factory.createNull(),
        ),
        ts.factory.createForOfStatement(
          undefined,
          ts.factory.createVariableDeclarationList(
            [ts.factory.createVariableDeclaration(FOR_LOOP_ITEM_NAME)],
            ts.NodeFlags.Const,
          ),
          ts.factory.createCallExpression(
            ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('Object'), 'values'),
            undefined,
            [ts.factory.createIdentifier(parameter)],
          ),
          createTypeHandlerCall(functionName, FOR_LOOP_ITEM_NAME),
        ),
      );
    case undefined:
      return ts.factory.createIfStatement(
        ts.factory.createPrefixUnaryExpression(
          ts.SyntaxKind.ExclamationToken,
          ts.factory.createCallExpression(
            ts.factory.createPropertyAccessExpression(
              ts.factory.createIdentifier(VISITED_OBJECTS_SET_NAME),
              ts.factory.createIdentifier('has'),
            ),
            undefined,
            [ts.factory.createIdentifier(parameter)],
          ),
        ),
        ts.factory.createExpressionStatement(
          ts.factory.createCallExpression(ts.factory.createIdentifier(functionName), undefined, [
            ts.factory.createIdentifier(parameter),
          ]),
        ),
      );
  }
}