Skip to content

Typescript errors with mapping.ts implementation #107

@hwilliams1

Description

@hwilliams1

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions