<commit_before>// tslint:disable:no-console

import * as glob from 'glob';
import * as path from 'path';
import * as ts from 'typescript';
import { Docs, Method, Methods, Tags } from '../docs/src/ts/types';

const CWD = process.cwd();
// tslint:disable-next-line:no-var-requires
const COMPILER_OPTIONS = require(path.join(CWD, 'tsconfig.json'));

const serializeTags = (tags: ts.JSDocTagInfo[]): Tags => {
  const ret: Tags = {};

  for (const tag of tags) {
    ret[tag.name] = tag.text;
  }

  return ret;
};

const serializeParameter = (symbol: ts.Symbol, checker: ts.TypeChecker) => {
  const name = symbol.getName();
  const type = checker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration as ts.Declaration);
  const typeName = checker.typeToString(type);

  return {
    name,
    type: typeName,
    optional: checker.isOptionalParameter(symbol.valueDeclaration as ts.ParameterDeclaration),
  };
};

const serializeNode = (node: ts.PropertyDeclaration, checker: ts.TypeChecker): Method => {
  const symbol = checker.getSymbolAtLocation(node.name);
  const name = symbol.getName();
  const description = ts.displayPartsToString(symbol.getDocumentationComment());
  const type = checker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration as ts.Declaration);
  const signatures = checker.getSignaturesOfType(type, ts.SignatureKind.Call);
  const tags = serializeTags(symbol.getJsDocTags());

  return {
    name,
    description,
    tags,<commit_msg>Get type aliases<commit_after>// tslint:disable:no-console

import * as glob from 'glob';
import * as path from 'path';
import * as ts from 'typescript';
import { Docs, Method, Methods, Tags } from '../docs/src/ts/types';

const CWD = process.cwd();
// tslint:disable-next-line:no-var-requires
const COMPILER_OPTIONS = require(path.join(CWD, 'tsconfig.json'));

const serializeTags = (tags: ts.JSDocTagInfo[]): Tags => {
  const ret: Tags = {};

  for (const tag of tags) {
    ret[tag.name] = tag.text;
  }

  return ret;
};

const getTypeAlias = (type: ts.Type): string | null => {
  if (type.aliasSymbol) {
    return (type.aliasSymbol.getDeclarations()[0] as ts.TypeAliasDeclaration).type.getText();
  }

  return null;
};

const serializeParameter = (symbol: ts.Symbol, checker: ts.TypeChecker) => {
  const name = symbol.getName();
  const type = checker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration as ts.Declaration);
  const typeName = checker.typeToString(type);
  const alias = getTypeAlias(type);

  return {
    name,
    type: alias ? alias : typeName,
    optional: checker.isOptionalParameter(symbol.valueDeclaration as ts.ParameterDeclaration),
  };
};

const serializeNode = (node: ts.PropertyDeclaration, checker: ts.TypeChecker): Method => {
  const symbol = checker.getSymbolAtLocation(node.name);
  const name = symbol.getName();
  const description = ts.displayPartsToString(symbol.getDocumentationComment());
  const type = checker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration as ts.Declaration);
  const signatures = checker.getSignaturesOfType(type, ts.SignatureKind.Call);
  const tags = serializeTags(symbol.getJsDocTags());

  return {
    name,
    description,
    tags,
{'fraction_non_alphanumeric': 0.13008130081300814, 'fraction_numerical': 0.00031269543464665416, 'mean_word_length': 4.6419753086419755, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1744366', 'n_tokens_mistral': 1000, 'n_tokens_neox': 992, 'n_words': 236}