Skip to content

Instantly share code, notes, and snippets.

@shellscape
Created September 4, 2021 01:18
Show Gist options
  • Save shellscape/be55ec79975ecf6564a7ffb58997f575 to your computer and use it in GitHub Desktop.
Save shellscape/be55ec79975ecf6564a7ffb58997f575 to your computer and use it in GitHub Desktop.
knex-stringcase TypeScript Definition

This defintion is from work by @eioo on this pull request Kequc/knex-stringcase#14 which the maintainer decided to decline only after making the contributor go through several revisions. I have no desire to maintain a @types package, but please feel free to copy and use as needed.

declare module 'knex-stringcase' {
import { Conventions } from 'stringcase';
type StringcaseFn = (str: string) => string;
type Stringcase = Conventions | StringcaseFn | (Conventions | StringcaseFn)[]
interface IKnexStringCaseConfig {
appStringcase?: Stringcase;
dbStringcase?: Stringcase;
beforePostProcessResponse?(result: any[] | object, queryContext: object): any[] | object;
beforeWrapIdentifier?(value: string, queryContext: object): string;
ignoreStringcase?(obj: object): boolean;
}
function knexStringcase<T>(config: T & IKnexStringCaseConfig): T;
export = knexStringcase;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment