<commit_before>import { FunctionLikeDeclaration, Identifier, TypeReferenceNode } from 'typescript';
import { Context } from '../contexts';
import { EmitResult, emit } from './';

const emitFunctionDeclaration = (node: FunctionLikeDeclaration, context: Context): string => {
  const return_type = emit(node.type, context).emitted_string;
  const function_name = emit(node.name, context).emitted_string;
  const parameters =
    node.parameters
      .map(p => ({ name: emit(p.name, context).emitted_string, type: emit(p.type, context).emitted_string}))
      .map(({ name, type }) => `${type} ${name}`)
      .join(', ');
  const body = emit(node.body, context).emitted_string;
  const declaration = `${return_type} ${function_name}(${parameters}) ${body}`;
  return declaration;
};

export const emitFunctionLikeDeclaration = (node: FunctionLikeDeclaration, context: Context): EmitResult => {
  return {
    context,
    emitted_string: emitFunctionDeclaration(node, context)
  };
}<commit_msg>Add emit for variable declaration<commit_after>import { FunctionLikeDeclaration, Identifier, TypeReferenceNode, VariableDeclaration } from 'typescript';
import { Context } from '../contexts';
import { EmitResult, emit, emitString } from './';

const emitFunctionDeclaration = (node: FunctionLikeDeclaration, context: Context): string => {
  const return_type = emit(node.type, context).emitted_string;
  const function_name = emit(node.name, context).emitted_string;
  const parameters =
    node.parameters
      .map(p => ({ name: emit(p.name, context).emitted_string, type: emit(p.type, context).emitted_string}))
      .map(({ name, type }) => `${type} ${name}`)
      .join(', ');
  const body = emit(node.body, context).emitted_string;
  const declaration = `${return_type} ${function_name}(${parameters}) ${body}`;
  return declaration;
};

export const emitFunctionLikeDeclaration = (node: FunctionLikeDeclaration, context: Context): EmitResult => {
  return {
    context,
    emitted_string: emitFunctionDeclaration(node, context)
  };
}

export const emitVariableDeclaration = ({ type, name, initializer }: VariableDeclaration, context: Context): EmitResult => {
  return {
    context,
    emitted_string: `${emitString(type, context)} ${emitString(name, context)} = ${emitString(initializer, context)}`
  }
};
{'fraction_non_alphanumeric': 0.14464594127806563, 'fraction_numerical': 0.0, 'mean_word_length': 5.228494623655914, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '657804', 'n_tokens_mistral': 657, 'n_tokens_neox': 658, 'n_words': 163}