sindresorhus / camelcase-keys

Convert object keys to camel case
MIT License
679 stars 92 forks source link

Improve type definition. #92

Closed Masa-Shin closed 2 years ago

Masa-Shin commented 2 years ago

Description

Some kind of values (such as functions, records, or promises) are incorrectly inferred as {} when deep option is enabled. It is because CamelCaseKeys accepts Record<string, any> and so it admits some non-record-like types such as functions while it infer them as {}. For example, () => number extends Record<string, any> and CamelCaseKeys<() => number> is {}.

Reproduction Link

This cause some trouble when you use types like FileList since many of its values would be inferred as {}. I fixed the issue by adding a condition for whether CamelCaseKeys<T[P]> is too wide or not.

sindresorhus commented 2 years ago

CI is failing

Masa-Shin commented 2 years ago

@sindresorhus Sorry, fixed.