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

Fix the TypeScript definition for TypeScript 3.5 #46

Closed
wants to merge 1 commit into from

Conversation

mskec
Copy link

@mskec mskec commented Oct 3, 2019

Similar to #38

The current definition doesn't allow accessing nested properties.

const obj = { a: { a1: '1' } };
const ccObj = camelcaseKeys(obj, { deep: true });
console.log(ccObj.a.a1); // 'a1' does not exist on type 'unknown'.

@sindresorhus
Copy link
Owner

The current behavior is intentional. #38 was about input arguments. This is about return value. The correct solution is to make it generic so it preserves the input type.

@mskec
Copy link
Author

mskec commented Oct 3, 2019

@sindresorhus what do you suggest how to make it generic? I'm quite new with typescript

@sindresorhus
Copy link
Owner

I don't have the time to look into this now. Moving this to #50.

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

Successfully merging this pull request may close these issues.

None yet

2 participants