Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript errors with mapping.ts implementation #107

Open
hwilliams1 opened this issue Feb 19, 2021 · 0 comments
Open

Typescript errors with mapping.ts implementation #107

hwilliams1 opened this issue Feb 19, 2021 · 0 comments

Comments

@hwilliams1
Copy link
Contributor

An issue has been identified regarding src/mapping/mapping.ts showing an error regarding the generic specification when running the tests. An initial solution has been found by changing from :

import camelCaseKeys from "camelcase-keys";
import snakeCaseKeys from "snakecase-keys";

export default class Mapping {
    public static camelCaseKeys<T> (input: any): T {
        return camelCaseKeys(input, { deep: true }) as T;
    }

    public static snakeCaseKeys<T> (input: any): T {
        return snakeCaseKeys(input, { deep: true }) as T;
    }
}

to instead be :

import camelCaseKeys from "camelcase-keys";
import snakeCaseKeys from "snakecase-keys";

type ObjArray = { [key: string]: any; }[]
type Obj = { [key: string]: any; }
type ObjOptions = Obj | ObjArray;

export default class Mapping {
    public static camelCaseKeys<T> (input: any): T {
        return camelCaseKeys(input, { deep: true }) as T;
    }

    public static snakeCaseKeys (input: ObjOptions) {
        return snakeCaseKeys(input, { deep: true });
    }
}

However changing the camelCaseKeys to be the same has brought up additional errors when running the tests, so further investigation will be needed regarding the changes required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant