value: getTSTypeWithResolvedTypes()

in src/utils/getTSType.ts [249:364]


          value: getTSTypeWithResolvedTypes(
            path.get('typeAnnotation'),
            typeParams,
            importer,
          ),
        },
      ],
    },
  };
}

function handleTSFunctionType(
  path: NodePath,
  typeParams: TypeParameters | null,
  importer: Importer,
): TSFunctionSignatureType {
  const type: TSFunctionSignatureType = {
    name: 'signature',
    type: 'function',
    raw: printValue(path),
    signature: {
      arguments: [],
      return: getTSTypeWithResolvedTypes(
        path.get('typeAnnotation'),
        typeParams,
        importer,
      ),
    },
  };

  path.get('parameters').each(param => {
    const typeAnnotation = getTypeAnnotation(param);
    const arg: FunctionArgumentType<TSFunctionSignatureType> = {
      name: param.node.name || '',
      type: typeAnnotation
        ? getTSTypeWithResolvedTypes(typeAnnotation, typeParams, importer)
        : undefined,
    };

    if (param.node.name === 'this') {
      type.signature.this = arg.type;
      return;
    }

    if (param.node.type === 'RestElement') {
      arg.name = param.node.argument.name;
      arg.rest = true;
    }

    type.signature.arguments.push(arg);
  });

  return type;
}

function handleTSTupleType(
  path: NodePath,
  typeParams: TypeParameters | null,
  importer: Importer,
): ElementsType<TSFunctionSignatureType> {
  const type: ElementsType<TSFunctionSignatureType> = {
    name: 'tuple',
    raw: printValue(path),
    elements: [],
  };

  path.get('elementTypes').each(param => {
    type.elements.push(getTSTypeWithResolvedTypes(param, typeParams, importer));
  });

  return type;
}

function handleTSTypeQuery(
  path: NodePath,
  typeParams: TypeParameters | null,
  importer: Importer,
): TypeDescriptor<TSFunctionSignatureType> {
  const resolvedPath = resolveToValue(path.get('exprName'), importer);
  if (resolvedPath && resolvedPath.node.typeAnnotation) {
    return getTSTypeWithResolvedTypes(
      resolvedPath.get('typeAnnotation'),
      typeParams,
      importer,
    );
  }

  return { name: path.node.exprName.name };
}

function handleTSTypeOperator(
  path: NodePath,
  _typeParams: TypeParameters | null,
  importer: Importer,
): TypeDescriptor<TSFunctionSignatureType> | null {
  if (path.node.operator !== 'keyof') {
    return null;
  }

  let value = path.get('typeAnnotation');
  if (t.TSTypeQuery.check(value.node)) {
    value = value.get('exprName');
  } else if (value.node.id) {
    value = value.get('id');
  }

  const resolvedPath = resolveToValue(value, importer);
  if (
    resolvedPath &&
    (t.ObjectExpression.check(resolvedPath.node) ||
      t.TSTypeLiteral.check(resolvedPath.node))
  ) {
    const keys = resolveObjectToNameArray(resolvedPath, importer, true);

    if (keys) {
      return {