bendrucker/snakecase-keys

Using typescript declaration files

emmyakin opened this issue · 1 comments

Hi,

How do I use the SnakeCaseKeys types and other declare in the type file in my own typescript definitions?

e.g.

// my type.ts file
type ApiResponse = {
    camelCaseA: string;
    camelCaseB: string;
    camelCaseC: {
        nestedCaseA: string;
        nestedCaseB: string;
    }
}

type ResultSet = {
    a: string,
    b: {
        camel_case_a: string;
        camel_case_b: string;
        camel_case_c: {
            nested_case_a: string;
            nested_case_b: string;
        }
    }
}


// it would be easier to write ResultSet as 
// my type.ts file

import type { SnakeCaseKeys } from 'snakecase-keys';

type ResultSet = {
    a: string,
    b: SnakeCaseKeys<ApiResponse, true, []>
}

The types are not exported, so I cannot import SnakeCaseKeys, I has assumed I can add a <reference types=snakecase-keys /> but this is not working either

Closed in #67