<commit_before>import { Connection } from 'mysql2';

type ObjStatic = { [key: string]: any };
type IfError = Error | undefined;
type OnlyErrorCallback = (err?: IfError) => void;
type YukariDeleteCallback = (err: IfError, deleted?: boolean, sql?: string) => void;
type YukariInsertCallback = (err: IfError, record?: Yukari|null, sql?: string) => void;
type YukariUpdateCallback = (err: IfError, record?: Yukari|null, sql?: string) => void;

type ResultCallback = (err: IfError, result?: any, sql?: string) => void;
type FindCallback = (err: IfError, row?: Yukari|null|ObjStatic|(Yukari|ObjStatic)[], sql?: string) => void;
type FindOneCallback = (err: IfError, record?: Yukari|null|ObjStatic, sql?: string) => void;

export interface BaseType<T> {
  name: string;
  needQuotes?: boolean;
  defaultValue?: T;

  restore(parsed: T): any;
  parse(orig: any): T;

  equal?: (a: any, b: any) => boolean;
}

interface _Type {
  String: BaseType<string>;
  Boolean: BaseType<boolean>;
  Integer: BaseType<number>;
  Float: BaseType<number>;
  Json: BaseType<ObjStatic>;
  Datetime: BaseType<Date>;

  $equal: (a: any, b: any) => boolean;
}

export const Type: _Type;

export class Toshihiko {
  constructor(adapter: any, options: object);

  database: string;

  execute(sql: string, params?: any[]|ResultCallback, callback?: ResultCallback): Promise<any>;
  define(collectionName: string, schema: any[], options?: any): Model;
}
<commit_msg>fix: add toJSON to BaseType<T><commit_after>import { Connection } from 'mysql2';

type ObjStatic = { [key: string]: any };
type IfError = Error | undefined;
type OnlyErrorCallback = (err?: IfError) => void;
type YukariDeleteCallback = (err: IfError, deleted?: boolean, sql?: string) => void;
type YukariInsertCallback = (err: IfError, record?: Yukari|null, sql?: string) => void;
type YukariUpdateCallback = (err: IfError, record?: Yukari|null, sql?: string) => void;

type ResultCallback = (err: IfError, result?: any, sql?: string) => void;
type FindCallback = (err: IfError, row?: Yukari|null|ObjStatic|(Yukari|ObjStatic)[], sql?: string) => void;
type FindOneCallback = (err: IfError, record?: Yukari|null|ObjStatic, sql?: string) => void;

export interface BaseType<T> {
  name: string;
  needQuotes?: boolean;
  defaultValue?: T;

  restore(parsed: T): any;
  parse(orig: any): T;

  equal?: (a: any, b: any) => boolean;
  toJSON?: (a: T) => any;
}

interface _Type {
  String: BaseType<string>;
  Boolean: BaseType<boolean>;
  Integer: BaseType<number>;
  Float: BaseType<number>;
  Json: BaseType<ObjStatic>;
  Datetime: BaseType<Date>;

  $equal: (a: any, b: any) => boolean;
}

export const Type: _Type;

export class Toshihiko {
  constructor(adapter: any, options: object);

  database: string;

  execute(sql: string, params?: any[]|ResultCallback, callback?: ResultCallback): Promise<any>;
  define(collectionName: string, schema: any[], options?: any): Model;
}

{'fraction_non_alphanumeric': 0.15836482308485056, 'fraction_numerical': 0.0006870491240123669, 'mean_word_length': 5.618181818181818, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 39, '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': '5721038', 'n_tokens_mistral': 959, 'n_tokens_neox': 938, 'n_words': 288}