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

Using function with inferred type does not resolve correct return type defaults #116

Closed
WoodyWoodsta opened this issue Oct 16, 2023 · 1 comment · Fixed by #117
Closed

Comments

@WoodyWoodsta
Copy link

If I have a function which has a return type involving an inferred generic type, the defaults on the call to the camelCaseKeys function return type incorrectly resolve to unknown:

export function handleResponse<T extends Record<string, unknown> | readonly unknown[]>(
  response: T,
): CamelCaseKeys<T, true> {
  return camelcaseKeys(response.data, { deep: true });
//^^^^^^ Type 'CamelCaseKeys<T, true, unknown, unknown, unknown, unknown, "">' is not assignable to type 'CamelCaseKeys<T, true>'
}

I expect the defaults to correctly resolve, as they do in the return type of my handleResponse function: CamelCaseKeys<T, true>.

@sindresorhus
Copy link
Owner

// @yutak23

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 a pull request may close this issue.

2 participants