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

Improve type definition. #92

Merged
merged 4 commits into from Jun 22, 2022
Merged

Conversation

Masa-Shin
Copy link
Contributor

@Masa-Shin Masa-Shin commented Jun 21, 2022

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.

@Masa-Shin Masa-Shin changed the title Improve type inference. Improve type definition. Jun 21, 2022
@Masa-Shin Masa-Shin force-pushed the fix-deep-type branch 3 times, most recently from 90fb08d to 71087d6 Compare June 21, 2022 09:41
@sindresorhus
Copy link
Owner

CI is failing

Type inferences for some kind of values(functions, records, promises,.etc) are not correct when deep option is enabled. It is because CamelCaseKeys type accepts Record<string, any> and then accepts some object-like types such as functions or promises.
@Masa-Shin
Copy link
Contributor Author

@sindresorhus
Sorry, fixed.

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